def test_load(self): input = ZLayer.Input(shape=(5, )) output = ZLayer.Dense(10)(input) zmodel = ZModel(input, output, name="graph1") tmp_path = create_tmp_path() zmodel.saveModel(tmp_path, None, True) model_reloaded = Net.load(tmp_path) input_data = np.random.random([3, 5]) self.compare_output_and_grad_input(zmodel, model_reloaded, input_data)
def test_save_load_Model(self): input = ZLayer.Input(shape=(5, )) output = ZLayer.Dense(10)(input) zmodel = ZModel(input, output, name="graph1") tmp_path = create_tmp_path() zmodel.saveModel(tmp_path, None, True) model_reloaded = Net.load(tmp_path) input_data = np.random.random([10, 5]) y = np.random.random([10, 10]) model_reloaded.compile(optimizer="adam", loss="mse") model_reloaded.fit(x=input_data, y=y, batch_size=8, nb_epoch=2)
def test_save_load_Sequential(self): zmodel = ZSequential() dense = ZLayer.Dense(10, input_dim=5) zmodel.add(dense) tmp_path = create_tmp_path() zmodel.saveModel(tmp_path, None, True) model_reloaded = Net.load(tmp_path) input_data = np.random.random([10, 5]) y = np.random.random([10, 10]) model_reloaded.compile(optimizer="adam", loss="mse") model_reloaded.fit(x=input_data, y=y, batch_size=8, nb_epoch=1)
def load_model(model_path=MODEL_PATH, model_weights_path=MODEL_WEIGHTS_PATH): model = Net.load(model_path, model_weights_path) return model