Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with tensorflow 2.0: module 'tensorflow_core._api.v2.train' has no attribute 'AdamOptimizer' #51

Open
hugocool opened this issue Dec 29, 2019 · 2 comments

Comments

@hugocool
Copy link

pip install tensorflow==2.0
import numpy as np
import tensorflow as tf

from tffm import TFFMClassifier

gives error:

AttributeError Traceback (most recent call last)
in
----> 1 from tffm import TFFMClassifier

~/anaconda3/lib/python3.7/site-packages/tffm/init.py in
----> 1 from .models import TFFMClassifier, TFFMRegressor
2
3 all = ['TFFMClassifier', 'TFFMRegressor']

~/anaconda3/lib/python3.7/site-packages/tffm/models.py in
2
3 import numpy as np
----> 4 from .base import TFFMBaseModel
5 from .utils import loss_logistic, loss_mse, sigmoid
6

~/anaconda3/lib/python3.7/site-packages/tffm/base.py in
1 import tensorflow as tf
----> 2 from .core import TFFMCore
3 from sklearn.base import BaseEstimator
4 from abc import ABCMeta, abstractmethod
5 import six

~/anaconda3/lib/python3.7/site-packages/tffm/core.py in
4
5
----> 6 class TFFMCore():
7 """This class implements underlying routines about creating computational graph.
8

~/anaconda3/lib/python3.7/site-packages/tffm/core.py in TFFMCore()
94 """
95 def init(self, order=2, rank=2, input_type='dense', loss_function=None,
---> 96 optimizer=tf.train.AdamOptimizer(learning_rate=0.01), reg=0,
97 init_std=0.01, use_diag=False, reweight_reg=False,
98 seed=None):

AttributeError: module 'tensorflow_core._api.v2.train' has no attribute 'AdamOptimizer'

@Pager07
Copy link

Pager07 commented Mar 10, 2020

FIX: Go to core.py file inside ttf folder. In the in the init function change optimizer to tf.keras.optimizers.Adam(....).
Why?
Read the following: https://stackoverflow.com/questions/55682718/module-tensorflow-api-v2-train-has-no-attribute-gradientdescentoptimizer

@jamborta
Copy link

jamborta commented Jun 8, 2020

I ported this to tf2, check it out here: https://github.com/jamborta/tffm2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants