refactored
This commit is contained in:
+3
-3
@@ -20,7 +20,7 @@ class RbmLayer:
|
||||
def train_batch(self, v_states: np.ndarray, cd_func: Callable):
|
||||
for epochs in range(self.params.num_epochs):
|
||||
# Contrastive divergence learning: calculate gradients
|
||||
cd_func(v_states, dwhv, dbh, dbv);
|
||||
dwhv, dbh, dbv = cd_func(v_states)
|
||||
|
||||
|
||||
|
||||
@@ -36,9 +36,9 @@ if __name__ == "__main__":
|
||||
v0 = uniform((1,2))
|
||||
h0 = uniform((1,3))
|
||||
|
||||
h1 = l1.v_to_h(v0)
|
||||
h1 = l1.state.v_to_h(v0)
|
||||
print(h1.shape)
|
||||
v1 = l1.h_to_v(h1)
|
||||
v1 = l1.state.h_to_v(h1)
|
||||
s_v1 = sample(v1)
|
||||
p_h = prob(s_v1)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user