Refine line display visdom
This commit is contained in:
parent
7f39f884fc
commit
76c9b7f05e
|
@ -28,10 +28,8 @@ from tools import utils, Train, Loader, WebVisual
|
||||||
import EvaluatorUnsuper
|
import EvaluatorUnsuper
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
batchsize = 128
|
batchsize = 128
|
||||||
|
|
||||||
|
|
||||||
# model = utils.SetDevice(Model.Net5Grad35())
|
# model = utils.SetDevice(Model.Net5Grad35())
|
||||||
# model = utils.SetDevice(Model.Net31535())
|
# model = utils.SetDevice(Model.Net31535())
|
||||||
model = utils.SetDevice(Model.Net3Grad335())
|
model = utils.SetDevice(Model.Net3Grad335())
|
||||||
|
@ -44,8 +42,6 @@ layer = 0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# traindata, testdata = Loader.MNIST(batchsize)
|
# traindata, testdata = Loader.MNIST(batchsize)
|
||||||
# traindata, testdata = Loader.RandomMnist(batchsize, style="Vertical")
|
# traindata, testdata = Loader.RandomMnist(batchsize, style="Vertical")
|
||||||
# traindata, testdata = Loader.RandomMnist(batchsize, style="Horizontal")
|
# traindata, testdata = Loader.RandomMnist(batchsize, style="Horizontal")
|
||||||
|
@ -59,24 +55,27 @@ traindata, testdata = Loader.Cifar10Mono(batchsize, num_workers=0, shuffle=True)
|
||||||
|
|
||||||
# weight = EvaluatorUnsuper.UnsuperLearnSearchWeight(model, layer, traindata, NumSearch=100000, SearchChannelRatio=8, Interation=10)
|
# weight = EvaluatorUnsuper.UnsuperLearnSearchWeight(model, layer, traindata, NumSearch=100000, SearchChannelRatio=8, Interation=10)
|
||||||
# np.save("WeightSearch.npy", weight)
|
# np.save("WeightSearch.npy", weight)
|
||||||
|
|
||||||
# weight = EvaluatorUnsuper.UnsuperLearnTrainWeight(model, layer, traindata, NumTrain=5000)
|
|
||||||
# np.save("WeightTrain.npy", weight)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# weight = np.load(CurrentPath+"WeightSearch.npy")
|
# weight = np.load(CurrentPath+"WeightSearch.npy")
|
||||||
# bestweight,index = EvaluatorUnsuper.UnsuperLearnFindBestWeight(model,layer,weight,traindata,128,100000)
|
# bestweight,index = EvaluatorUnsuper.UnsuperLearnFindBestWeight(model,layer,weight,traindata,128,100000)
|
||||||
# np.save(CurrentPath+"bestweightSearch.npy", bestweight)
|
# np.save(CurrentPath+"bestweightSearch.npy", bestweight)
|
||||||
|
# bestweight = np.load(CurrentPath+"bestweightSearch.npy")
|
||||||
# utils.NumpyToImage(bestweight, CurrentPath+"image")
|
# utils.NumpyToImage(bestweight, CurrentPath+"image")
|
||||||
|
# EvaluatorUnsuper.SetModelConvWeight(model,layer,bestweight)
|
||||||
|
# utils.SaveModel(model,CurrentPath+"/checkpointSearch.pkl")
|
||||||
|
|
||||||
|
|
||||||
# weight = np.load(CurrentPath+"WeightTrain.npy")
|
|
||||||
# bestweight, index = EvaluatorUnsuper.UnsuperLearnFindBestWeight(
|
|
||||||
# model, layer, weight, traindata, databatchs=16, interation=1000000)
|
# weight = EvaluatorUnsuper.UnsuperLearnTrainWeight(model, layer, traindata, NumTrain=5000)
|
||||||
# np.save(CurrentPath+"bestweightTrain.npy", bestweight)
|
# np.save("WeightTrain.npy", weight)
|
||||||
# utils.NumpyToImage(bestweight, CurrentPath+"image")
|
weight = np.load(CurrentPath+"WeightTrain.npy")
|
||||||
|
bestweight, index = EvaluatorUnsuper.UnsuperLearnFindBestWeight(model, layer, weight, traindata, databatchs=128, interation=1000000)
|
||||||
|
np.save(CurrentPath+"bestweightTrain.npy", bestweight)
|
||||||
|
bestweight = np.load(CurrentPath+"bestweightTrain.npy")
|
||||||
|
utils.NumpyToImage(bestweight, CurrentPath+"image")
|
||||||
|
# EvaluatorUnsuper.SetModelConvWeight(model,layer,bestweight)
|
||||||
|
# utils.SaveModel(model,CurrentPath+"/checkpointTrain.pkl")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -95,22 +94,6 @@ traindata, testdata = Loader.Cifar10Mono(batchsize, num_workers=0, shuffle=True)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# weight = np.load(CurrentPath+"bestweightSearch.npy")
|
|
||||||
# EvaluatorUnsuper.SetModelConvWeight(model,layer,weight)
|
|
||||||
# utils.SaveModel(model,CurrentPath+"/checkpointSearch.pkl")
|
|
||||||
|
|
||||||
|
|
||||||
weight = np.load(CurrentPath+"bestweightTrain.npy")
|
|
||||||
EvaluatorUnsuper.SetModelConvWeight(model,layer,weight)
|
|
||||||
utils.SaveModel(model,CurrentPath+"/checkpointTrain.pkl")
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# utils.NumpyToImage(weight, CurrentPath+"image")
|
# utils.NumpyToImage(weight, CurrentPath+"image")
|
||||||
# utils.SaveModel(model,CurrentPath+"/checkpoint.pkl")
|
# utils.SaveModel(model,CurrentPath+"/checkpoint.pkl")
|
||||||
print("save model sucess")
|
print("save model sucess")
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 413 B After Width: | Height: | Size: 409 B |
Binary file not shown.
|
@ -36,11 +36,8 @@ class Line():
|
||||||
self.size = 0
|
self.size = 0
|
||||||
self.win = windows
|
self.win = windows
|
||||||
|
|
||||||
def AppendData(self, y):
|
def AppendData(self, y, x=None):
|
||||||
self.win.AppendData(self, y)
|
self.win.AppendData(self, y, x)
|
||||||
|
|
||||||
def AppendData(self, x, y):
|
|
||||||
self.win.AppendData(self, x, y)
|
|
||||||
|
|
||||||
|
|
||||||
class LineWin():
|
class LineWin():
|
||||||
|
@ -70,26 +67,16 @@ class LineWin():
|
||||||
)
|
)
|
||||||
return Line(linename, len(y))
|
return Line(linename, len(y))
|
||||||
|
|
||||||
def AppendData(self, line, y):
|
def AppendData(self, line, y, x=None):
|
||||||
if not isinstance(y, list):
|
|
||||||
y = [y]
|
y = [y]
|
||||||
self.viz.line(
|
Y = np.array(y).reshape((-1))
|
||||||
X=np.array(range(line.size, line.size+len(y))),
|
X = []
|
||||||
Y=np.array(y),
|
if x:
|
||||||
win=self.win,
|
|
||||||
update="append",
|
|
||||||
name=line.name
|
|
||||||
)
|
|
||||||
line.size = line.size + len(y)
|
|
||||||
|
|
||||||
def AppendData(self, line, x, y):
|
|
||||||
if not isinstance(y, list) and not isinstance(y, np.ndarray):
|
|
||||||
y = [y]
|
|
||||||
if not isinstance(x, list) and not isinstance(x, np.ndarray):
|
|
||||||
x = [x]
|
x = [x]
|
||||||
X = np.array(x)
|
X = np.array(X).reshape((-1))
|
||||||
Y = np.array(y)
|
else:
|
||||||
X = X[0:len(Y)]
|
X = np.array(range(line.size, line.size+len(Y)))
|
||||||
|
|
||||||
self.viz.line(
|
self.viz.line(
|
||||||
Y=Y,
|
Y=Y,
|
||||||
X=X,
|
X=X,
|
||||||
|
|
|
@ -175,7 +175,7 @@ def NumpyToImage(numpydate, foldname, title="", maxImageWidth=128, maxImageHeigh
|
||||||
data = numpydate.reshape((-1, numpydate.shape[-2], numpydate.shape[-1]))
|
data = numpydate.reshape((-1, numpydate.shape[-2], numpydate.shape[-1]))
|
||||||
datashape = data.shape
|
datashape = data.shape
|
||||||
|
|
||||||
newdata = np.ones((datashape[0],datashape[1]+1,datashape[2]+1))*numpydatemin
|
newdata = np.zeros((datashape[0],datashape[1]+1,datashape[2]+1))
|
||||||
newdata[:, 0:datashape[1], 0:datashape[2]]=data
|
newdata[:, 0:datashape[1], 0:datashape[2]]=data
|
||||||
datashape = newdata.shape
|
datashape = newdata.shape
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue