dropout_rate=0.5, // with dropout here.
kernel_size=6,
dilations=[1, 2, 4])(x)
x = Dropout(0.5)(x) // and dropout here.
x = Dense(1, activation="sigmoid")(x)
model = Model(inputs=[i], outputs=[x])
if os.path.exists("tcn.npz"):
// Load checkpoint if file exists.
w = np.load("tcn.npz", allow_pickle=True)["w"]
print("Model reloaded.")
model.set_weights(w.tolist())
else:
// Save the checkpoint.
w = np.array(model.get_weights())
np.savez_compressed(file="tcn.npz", w=w, allow_pickle=True)
print("First time.")
// Make inference.
After Change
// load model from file
loaded_json = open(r"model.json", "r").read()
reloaded_model = model_from_json(loaded_json, custom_objects={"TCN": TCN})
// restore weights
reloaded_model.load_weights(r"weights.h5")