- simplified TrainingParams.from_dict
- fixed test_rbm
This commit is contained in:
+2
-11
@@ -32,17 +32,8 @@ class TrainingParams:
|
|||||||
@classmethod
|
@classmethod
|
||||||
def from_dict(cls, params: dict):
|
def from_dict(cls, params: dict):
|
||||||
obj = TrainingParams()
|
obj = TrainingParams()
|
||||||
obj.learning_rate = params["learningRate"]
|
for key, value in params.items():
|
||||||
obj.momentum = params["momentum"]
|
setattr(obj, key, value)
|
||||||
obj.weight_decay = params["weightDecay"]
|
|
||||||
obj.l2_lambda = params["l2_lambda"]
|
|
||||||
obj.num_epochs = params["numEpochs"]
|
|
||||||
obj.num_gibbs_samples = params["numGibbs"]
|
|
||||||
obj.mini_batch_size = params["miniBatchSize"]
|
|
||||||
obj.do_rao_blackwell = params["doRaoBlackwell"]
|
|
||||||
obj.do_gibbs_sample_visible = params["gibbsDoSampleVisible"]
|
|
||||||
obj.do_gibbs_sample_hidden = params["gibbsDoSampleHidden"]
|
|
||||||
obj.do_batch_sample = params["doSampleBatch"]
|
|
||||||
|
|
||||||
return obj
|
return obj
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ from rbm.stack_factory import StackFactory
|
|||||||
from rbm.status import Status
|
from rbm.status import Status
|
||||||
from rbm.stack_deep import StackDeep
|
from rbm.stack_deep import StackDeep
|
||||||
from rbm.matrix import Mat, np, convert, read_armadillo
|
from rbm.matrix import Mat, np, convert, read_armadillo
|
||||||
|
from rbm.entity import Entity
|
||||||
|
|
||||||
def cv_show(name: str, vec: Mat, shape):
|
def cv_show(name: str, vec: Mat, shape):
|
||||||
img = cv.Mat(convert(np.resize(vec, shape)))
|
img = cv.Mat(convert(np.resize(vec, shape)))
|
||||||
@@ -18,10 +19,10 @@ class MyStatus(Status):
|
|||||||
self.batch = _batch
|
self.batch = _batch
|
||||||
self.index = 0
|
self.index = 0
|
||||||
|
|
||||||
def on_report(self, status: dict) -> bool:
|
def on_report(self, entity: Entity, status: dict) -> bool:
|
||||||
do_continue = True
|
do_continue = True
|
||||||
# print status values
|
# print status values
|
||||||
Status.print_status(status)
|
Status.print_status(entity, status)
|
||||||
# Shape of training vector
|
# Shape of training vector
|
||||||
shape = self.stack.from_index(0).shape[0:2] + (1,)
|
shape = self.stack.from_index(0).shape[0:2] + (1,)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user