Entity: added property enable training

This commit is contained in:
2026-01-06 09:44:29 +01:00
parent b1fe7229fa
commit ec5d259ff7
2 changed files with 5 additions and 3 deletions
+2 -1
View File
@@ -69,10 +69,11 @@ class Entity:
GB_RBM = "GB-RBM"
GG_RBM = "GG-RBM"
def __init__(self, shape: tuple[int, int], params: EntityParams, training_params: TrainingParams|None = None):
def __init__(self, shape: tuple[int, int], params: EntityParams, training_params: TrainingParams|None = None, enable_training: bool = True):
self.shape = shape
self.params = params
self.training_params = training_params
self.enable_training = enable_training
self.state = RbmState.from_layer_params(shape)
self.grad = RbmState.from_layer_params(shape)
self.type = None
+3 -2
View File
@@ -24,8 +24,9 @@ class Model(ABC):
entities = self.objects(Entity)
_batch = np.copy(batch)
for entity in entities:
if train(entity, _batch, Status()):
_batch = entity.forward(_batch)
if entity.enable_training:
train(entity, _batch, Status())
_batch = entity.forward(_batch)
def forward(self, x: Mat) -> Mat:
pass