Open Vlasovets opened 2 years ago
Hello,
I am sorry that we don’t have time to migration to the new tensorflow as the first author has graduated. Can you install the old version of tensorflow and give it a try? We have received feedbacks that the old version works fine.
Sent from my iPhone
On Jun 8, 2022, at 8:40 AM, Oleg @.***> wrote:
Hello!
I'm trying to run your model, but there are a couple of problems due to the recent upgrades of Tensorflow, I guess.
from keras.layers.merge import _Merge is deprecated, and one can use Layer in RandomWeightedAverage. That has solved the problem of initiating the model, but I'm still unable to train it with the default parameters, here is the error message if you could take a look, thank you!
ITERS = 500000 BATCH_SIZE = 32 SAVE_INTERVAL = 1000
mbgan.train(data_o_case, iteration=ITERS, batch_size=BATCH_SIZE, n_critic=5, n_generator=1, save_fn=get_save_fn(taxa_list), save_interval=SAVE_INTERVAL, experiment_dir=EXP_DIR, pre_processor=None, verbose=0) ValueError: in user code:
File "/usr/local/lib/python3.7/dist-packages/keras/engine/training.py", line 1021, in train_function * return step_function(self, iterator) File "/usr/local/lib/python3.7/dist-packages/keras/engine/training.py", line 1010, in step_function ** outputs = model.distribute_strategy.run(run_step, args=(data,)) File "/usr/local/lib/python3.7/dist-packages/keras/engine/training.py", line 1000, in run_step ** outputs = model.train_step(data) File "/usr/local/lib/python3.7/dist-packages/keras/engine/training.py", line 859, in train_step y_pred = self(x, training=True) File "/usr/local/lib/python3.7/dist-packages/keras/utils/traceback_utils.py", line 67, in error_handler raise e.with_traceback(filtered_tb) from None File "/usr/local/lib/python3.7/dist-packages/keras/engine/input_spec.py", line 200, in assert_input_compatibility raise ValueError(f'Layer "{layer_name}" expects {len(input_spec)} input(s),' ValueError: Exception encountered when calling layer "model_37" (type Functional). Layer "model_35" expects 1 input(s), but it received 2 input tensors. Inputs received: [<tf.Tensor 'IteratorGetNext:0' shape=(32, 719) dtype=float32>, <tf.Tensor 'model_37/model_36/sequential_30/activation_55/Softmax:0' shape=(32, 719) dtype=float32>] Call arguments received: • inputs=('tf.Tensor(shape=(32, 719), dtype=float32)', 'tf.Tensor(shape=(32, 100), dtype=float32)') • training=True • mask=None
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.
thank you for a quick reply! I was trying Keras v2.2.4 as was mentioned in another issue, and tensorflow v2.1.4 so far it did not work out, could confirm that I use the correct versions?
Hi! I also ran into this problem, and I replaced the inheritance from Merge
with Add
. My RandomWeightedAverage
layer now looks like this:
class RandomWeightedAverage(Add):
def _merge_function(self, inputs):
batch_size = K.shape(inputs[0])[0]
alpha = K.random_uniform((batch_size, 1))
return (alpha * inputs[0]) + ((1 - alpha) * inputs[1])
Additionally, you get a shape error when sampling alpha with the dimensions (batch_size, 1, 1, 1)
; instead, (batch_size, 1)
worked for me. However, I am still getting NaN loss for my outputs. Hope this helps!
Hello!
I'm trying to run your model, but there are a couple of problems due to the recent upgrades of Tensorflow, I guess.
from keras.layers.merge import _Merge
is deprecated, and one can useLayer
in RandomWeightedAverage. That has solved the problem of initiating the model, but I'm still unable to train it with the default parameters, here is the error message if you could take a look, thank you!