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
|
||||
|
||||
|
||||
|
||||
batchsize = 128
|
||||
|
||||
|
||||
# model = utils.SetDevice(Model.Net5Grad35())
|
||||
# model = utils.SetDevice(Model.Net31535())
|
||||
model = utils.SetDevice(Model.Net3Grad335())
|
||||
|
@ -44,8 +42,6 @@ layer = 0
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
# traindata, testdata = Loader.MNIST(batchsize)
|
||||
# traindata, testdata = Loader.RandomMnist(batchsize, style="Vertical")
|
||||
# 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)
|
||||
# np.save("WeightSearch.npy", weight)
|
||||
|
||||
# weight = EvaluatorUnsuper.UnsuperLearnTrainWeight(model, layer, traindata, NumTrain=5000)
|
||||
# np.save("WeightTrain.npy", weight)
|
||||
|
||||
|
||||
|
||||
|
||||
# weight = np.load(CurrentPath+"WeightSearch.npy")
|
||||
# bestweight,index = EvaluatorUnsuper.UnsuperLearnFindBestWeight(model,layer,weight,traindata,128,100000)
|
||||
# np.save(CurrentPath+"bestweightSearch.npy", bestweight)
|
||||
# bestweight = np.load(CurrentPath+"bestweightSearch.npy")
|
||||
# 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)
|
||||
# np.save(CurrentPath+"bestweightTrain.npy", bestweight)
|
||||
# utils.NumpyToImage(bestweight, CurrentPath+"image")
|
||||
|
||||
|
||||
# weight = EvaluatorUnsuper.UnsuperLearnTrainWeight(model, layer, traindata, NumTrain=5000)
|
||||
# np.save("WeightTrain.npy", weight)
|
||||
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.SaveModel(model,CurrentPath+"/checkpoint.pkl")
|
||||
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.win = windows
|
||||
|
||||
def AppendData(self, y):
|
||||
self.win.AppendData(self, y)
|
||||
|
||||
def AppendData(self, x, y):
|
||||
self.win.AppendData(self, x, y)
|
||||
def AppendData(self, y, x=None):
|
||||
self.win.AppendData(self, y, x)
|
||||
|
||||
|
||||
class LineWin():
|
||||
|
@ -70,26 +67,16 @@ class LineWin():
|
|||
)
|
||||
return Line(linename, len(y))
|
||||
|
||||
def AppendData(self, line, y):
|
||||
if not isinstance(y, list):
|
||||
y = [y]
|
||||
self.viz.line(
|
||||
X=np.array(range(line.size, line.size+len(y))),
|
||||
Y=np.array(y),
|
||||
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):
|
||||
def AppendData(self, line, y, x=None):
|
||||
y = [y]
|
||||
Y = np.array(y).reshape((-1))
|
||||
X = []
|
||||
if x:
|
||||
x = [x]
|
||||
X = np.array(x)
|
||||
Y = np.array(y)
|
||||
X = X[0:len(Y)]
|
||||
X = np.array(X).reshape((-1))
|
||||
else:
|
||||
X = np.array(range(line.size, line.size+len(Y)))
|
||||
|
||||
self.viz.line(
|
||||
Y=Y,
|
||||
X=X,
|
||||
|
|
|
@ -175,7 +175,7 @@ def NumpyToImage(numpydate, foldname, title="", maxImageWidth=128, maxImageHeigh
|
|||
data = numpydate.reshape((-1, numpydate.shape[-2], numpydate.shape[-1]))
|
||||
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
|
||||
datashape = newdata.shape
|
||||
|
||||
|
|
Loading…
Reference in New Issue