[train]
- reset grad at start of epoch [state] - init(): set default parameter mu=0
This commit is contained in:
+1
-1
@@ -55,7 +55,7 @@ class RbmState:
|
|||||||
np.savez(filename, whv=self.w_hv, bv=self.b_v, bh=self.b_h)
|
np.savez(filename, whv=self.w_hv, bv=self.b_v, bh=self.b_h)
|
||||||
print(f"{filename} saved successfully!")
|
print(f"{filename} saved successfully!")
|
||||||
|
|
||||||
def init(self, mu: float = 0.5, std: float = 1.0):
|
def init(self, mu: float = 0.0, std: float = 1.0):
|
||||||
self.w_hv = uniform(self.w_hv.shape, mu, std)
|
self.w_hv = uniform(self.w_hv.shape, mu, std)
|
||||||
self.b_v = uniform(self.b_v.shape, 0, 0)
|
self.b_v = uniform(self.b_v.shape, 0, 0)
|
||||||
self.b_h = uniform(self.b_h.shape, 0, 0)
|
self.b_h = uniform(self.b_h.shape, 0, 0)
|
||||||
|
|||||||
+2
-2
@@ -218,9 +218,9 @@ def train(entity: Entity, batch: Mat, status: Status):
|
|||||||
if not keep_running:
|
if not keep_running:
|
||||||
break
|
break
|
||||||
|
|
||||||
|
# Reset gradient
|
||||||
|
entity.grad_zero()
|
||||||
for mini_batch in to_mini_batch(batch, mini_batch_size):
|
for mini_batch in to_mini_batch(batch, mini_batch_size):
|
||||||
# Reset gradient
|
|
||||||
entity.grad_zero()
|
|
||||||
# Contrastive divergence learning: calculate gradients
|
# Contrastive divergence learning: calculate gradients
|
||||||
dwhv, dbv, dbh = cd_func(entity, mini_batch)
|
dwhv, dbv, dbh = cd_func(entity, mini_batch)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user