refactored
This commit is contained in:
+3
-2
@@ -94,13 +94,14 @@ def train(entity: Entity, batch: Mat, params: TrainingParams, status: Status, cd
|
||||
if not keep_running:
|
||||
break
|
||||
|
||||
entity.prepare()
|
||||
entity.grad_zero()
|
||||
for epochs in range(params.num_epochs):
|
||||
# Contrastive divergence learning: calculate gradients
|
||||
dwhv, dbv, dbh, _ = cd_func(entity, mini_batch, params)
|
||||
|
||||
# Adjust weight and biases
|
||||
entity.adjust(dbv, dbh, dwhv, learning_rate=params.learning_rate/batch.shape[0], momentum=params.momentum, weight_decay=params.weight_decay)
|
||||
grad = entity.grad_compute(dbv, dbh, dwhv, learning_rate=params.learning_rate/batch.shape[0], momentum=params.momentum, weight_decay=params.weight_decay)
|
||||
entity.state_adjust(grad)
|
||||
|
||||
# check if status update is needed
|
||||
if status.want_report(round(progress)):
|
||||
|
||||
Reference in New Issue
Block a user