Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
save_checkpoint: (bool) whether to save checkpoint
automatic_correction: (bool) correct nan errors
**kwargs:
"""
# load from saved model
if prev_model:
self.load_weights(prev_model)
is_classification = 'entropy' in self.model.loss
monitor = 'val_acc' if is_classification else 'val_mae'
mode = 'max' if is_classification else 'min'
dirname = kwargs.pop('dirname', 'callback')
if not os.path.isdir(dirname):
os.makedirs(dirname)
if callbacks is None:
# with this call back you can stop the model training by `touch STOP`
callbacks = [ManualStop()]
train_nb_atoms = [len(i['atom']) for i in train_graphs]
train_targets = [self.target_scaler.transform(i, j) for i, j in zip(train_targets, train_nb_atoms)]
if validation_graphs is not None:
filepath = os.path.join(dirname, '%s_{epoch:05d}_{%s:.6f}.hdf5' % (monitor, monitor))
val_nb_atoms = [len(i['atom']) for i in validation_graphs]
validation_targets = [self.target_scaler.transform(i, j) for i, j in zip(validation_targets, val_nb_atoms)]
val_inputs = self.graph_converter.get_flat_data(validation_graphs, validation_targets)
val_generator = self._create_generator(*val_inputs,
batch_size=batch_size)
steps_per_val = int(np.ceil(len(validation_graphs) / batch_size))
if automatic_correction:
callbacks.extend([ReduceLRUponNan(filepath=filepath,
monitor=monitor,
mode=mode,
save_checkpoint: (bool) whether to save checkpoint
automatic_correction: (bool) correct nan errors
**kwargs:
"""
# load from saved model
if prev_model:
self.load_weights(prev_model)
is_classification = 'entropy' in self.model.loss
monitor = 'val_acc' if is_classification else 'val_mae'
mode = 'max' if is_classification else 'min'
dirname = kwargs.pop('dirname', 'callback')
if not os.path.isdir(dirname):
os.makedirs(dirname)
if callbacks is None:
# with this call back you can stop the model training by `touch STOP`
callbacks = [ManualStop()]
train_nb_atoms = [len(i['atom']) for i in train_graphs]
train_targets = [self.target_scaler.transform(i, j) for i, j in zip(train_targets, train_nb_atoms)]
if validation_graphs is not None:
filepath = os.path.join(dirname, '%s_{epoch:05d}_{%s:.6f}.hdf5' % (monitor, monitor))
val_nb_atoms = [len(i['atom']) for i in validation_graphs]
validation_targets = [self.target_scaler.transform(i, j) for i, j in zip(validation_targets, val_nb_atoms)]
val_inputs = self.graph_converter.get_flat_data(validation_graphs, validation_targets)
val_generator = self._create_generator(*val_inputs,
batch_size=batch_size)
steps_per_val = int(np.ceil(len(validation_graphs) / batch_size))
if automatic_correction:
callbacks.extend([ReduceLRUponNan(filepath=filepath,
monitor=monitor,
mode=mode,