00de689e6624b4b3c312c921226ad23f49a79229,deeppavlov/core/models/keras_model.py,KerasModel,load,#KerasModel#Any#Any#Any#Any#Any#Any#Any#Any#Any#Any#Any#,121
Before Change
metrics_names = metrics_names.split(" ")
metrics_funcs = []
for i in range(len(metrics_names)):
metrics_func = getattr(keras.metrics, metrics_names[i], None)
if callable(metrics_func):
metrics_funcs.append(metrics_func)
else:
metrics_func = getattr(add_metrics_file, metrics_names[i], None)
if callable(metrics_func):
metrics_funcs.append(metrics_func)
else:
raise AttributeError("Metric {} is not defined".format(metrics_names[i]))
model.compile(optimizer=optimizer_,
loss=loss,
metrics=metrics_funcs,
loss_weights=loss_weights,
After Change
opt_path = "{}_opt.json".format(self.model_path)
weights_path = "{}.h5".format(self.model_path)
if Path(opt_path).exists() and Path(weights_path).exists():
self.opt = read_json(opt_path)
model_func = getattr(self, model_name, None)
if callable(model_func):
model = model_func(params=self.opt)
else:
raise AttributeError("Model {} is not defined".format(model_name))
print("Loading weights from `{}{}`".format(self._model_file, ".h5"))
model.load_weights(weights_path)
optimizer_func = getattr(keras.optimizers, optimizer_name, None)
if callable(optimizer_func):
optimizer_ = optimizer_func(lr=lr, decay=decay)
else:
raise AttributeError("Optimizer {} is not callable".format(optimizer_name))
loss_func = getattr(keras.losses, loss_name, None)
if callable(loss_func):
loss = loss_func
else:
raise AttributeError("Loss {} is not defined".format(loss_name))
metrics_names = metrics_names.split(" ")
metrics_funcs = []
for i in range(len(metrics_names)):
metrics_func = getattr(keras.metrics, metrics_names[i], None)
if callable(metrics_func):
metrics_funcs.append(metrics_func)
else:
metrics_func = getattr(add_metrics_file, metrics_names[i], None)
if callable(metrics_func):
metrics_funcs.append(metrics_func)
else:
raise AttributeError("Metric {} is not defined".format(metrics_names[i]))
model.compile(optimizer=optimizer_,
loss=loss,
metrics=metrics_funcs,
loss_weights=loss_weights,
sample_weight_mode=sample_weight_mode,
weighted_metrics=weighted_metrics,
target_tensors=target_tensors)
return model
else:
self.init_model_from_scratch(model_name, optimizer_name,
lr, decay, loss_name)
@abstractmethod
def train_on_batch(self, batch):
Method trains the model on a single batch of data
In pattern: SUPERPATTERN
Frequency: 4
Non-data size: 3
Instances
Project Name: deepmipt/DeepPavlov
Commit Name: 00de689e6624b4b3c312c921226ad23f49a79229
Time: 2018-01-19
Author: ol.gure@gmail.com
File Name: deeppavlov/core/models/keras_model.py
Class Name: KerasModel
Method Name: load
Project Name: NervanaSystems/coach
Commit Name: bf2036b2841b29496a6e7f180b90ecd6b773e030
Time: 2018-11-23
Author: balaji.warft@gmail.com
File Name: rl_coach/data_stores/s3_data_store.py
Class Name: S3DataStore
Method Name: save_to_store
Project Name: AlexEMG/DeepLabCut
Commit Name: 857cb1f38abfc3f467b6a8e53ae54365e05fcff2
Time: 2019-02-23
Author: amathis@fas.harvard.edu
File Name: deeplabcut/create_project/add.py
Class Name:
Method Name: add_new_videos
Project Name: tensorlayer/tensorlayer
Commit Name: 35b2c4917344f338eda67c78673cf4064b3b4265
Time: 2020-02-07
Author: 34995488+Tokarev-TT-33@users.noreply.github.com
File Name: examples/reinforcement_learning/tutorial_DQN.py
Class Name:
Method Name: