recommenders-team / recommenders

Best Practices on Recommendation Systems
https://recommenders-team.github.io/recommenders/intro.html
MIT License
18.82k stars 3.07k forks source link

[ASK] Multinomial VAE not working #1915

Open kone807 opened 1 year ago

kone807 commented 1 year ago

Description

I am running Multinomial VAE on movielens 1m dataset as given in the example notebook but getting an error when fitting the model. The line of code is -

with Timer() as t: model_without_anneal.fit(x_train=train_data, x_valid=val_data, x_val_tr=val_data_tr, x_val_te=val_data_te_ratings, # with the original ratings mapper=am_val ) print("Took {} seconds for training.".format(t))

and the corresponding error is -

Error message - TypeError: You are passing KerasTensor(type_spec=TensorSpec(shape=(), dtype=tf.float32, name=None), name='Placeholder:0', description="created by layer 'tf.cast_8'"), an intermediate Keras symbolic input/output, to a TF API that does not allow registering custom dispatchers, such as tf.cond, tf.function, gradient tapes, or tf.map_fn. Keras Functional model construction only supports TF API calls that do support dispatching, such as tf.math.add or tf.reshape. Other APIs cannot be called directly on symbolic Kerasinputs/outputs. You can work around this limitation by putting the operation in a custom Keras layer call and calling that layer on this symbolic input/output.

Please guide what can be done about this. Thank you.

Other Comments

Wei2624 commented 1 year ago

Run: from tensorflow.python.framework.ops import disable_eager_execution disable_eager_execution() before building the model works for me.

kone807 commented 1 year ago

Run: from tensorflow.python.framework.ops import disable_eager_execution disable_eager_execution() before building the model works for me.

This resolved the previous error, however, now I get error in Adam optimizer -> AttributeError: 'Adam' object has no attribute 'get_updates'

The resolution I found was to add .legacy while making the import but that won't be feasible given that Adam is being imported in the recommenders file which I am using as a blackbox. Please suggest any measures to handle this. Thank you.

mariaKlv commented 1 year ago

The aforementioned error is still persistent, while the aforementioned solution did not seem any helpful for my case. Are the any updates yet?

miguelgfierro commented 1 year ago

Reopening issue