qubvel / efficientnet

Implementation of EfficientNet model. Keras and TensorFlow Keras.
https://arxiv.org/abs/1905.11946
Apache License 2.0
2.07k stars 471 forks source link

AttributeError: module 'tensorflow.python.keras.api._v1.keras.backend' has no attribute 'is_keras_tensor' #68

Closed SamuelMarks closed 5 years ago

SamuelMarks commented 5 years ago
runners.py", line 80, in train
  model = model_fn(inputs, problem.output_spec())
File "/opt/venvs/tflow3.6/lib/python3.6/site-packages/gin/config.py", line 1032, in wrapper
  utils.augment_exception_message_and_reraise(e, err_str)
File "/opt/venvs/tflow3.6/lib/python3.6/site-packages/gin/utils.py", line 49, in augment_exception_message_and_reraise
  six.raise_from(proxy.with_traceback(exception.__traceback__), None)
File "<string>", line 3, in raise_from
File "/opt/venvs/tflow3.6/lib/python3.6/site-packages/gin/config.py", line 1009, in wrapper
  return fn(*new_args, **new_kwargs)
File "/opt/venvs/tflow3.6/lib/python3.6/site-packages/ml_glaucoma/models/efficientnet.py", line 45, in efficient_net
  input_tensor=inputs, **kwargs).outputs
File "/opt/venvs/tflow3.6/lib/python3.6/site-packages/efficientnet/__init__.py", line 57, in wrapper
  return func(*args, **kwargs)
File "/opt/venvs/tflow3.6/lib/python3.6/site-packages/efficientnet/model.py", line 548, in EfficientNetB4
  **kwargs)
File "/opt/venvs/tflow3.6/lib/python3.6/site-packages/efficientnet/model.py", line 369, in EfficientNet
  if not backend.is_keras_tensor(input_tensor):
File "/opt/venvs/tflow3.6/lib/python3.6/site-packages/tensorflow/python/util/deprecation_wrapper.py", line 106, in __getattr__
  attr = getattr(self._dw_wrapped_module, name)
Sep 08 03:15:55 ip-172-31-25-230 python[3136]: AttributeError: module 'tensorflow.python.keras.api._v1.keras.backend' has no attribute 'is_keras_tensor'
In call to configurable 'efficient_net' (<function efficient_net at 0x7feef701ce18>)
anhmeow commented 5 years ago

Got the same issue with the following code (executed on a kaggle notebook):

!pip install -U --pre efficientnet
from efficientnet.tfkeras import EfficientNetB0
import tensorflow as tf

inputs = tf.keras.layers.Input((None, None, 3))
base_model = EfficientNetB0(weights='imagenet',include_top=False, classes=2, input_tensor=inputs)
outputs = base_model.output
model = tf.keras.Model(inputs=[inputs], outputs=[outputs])
model.summary()
SamuelMarks commented 5 years ago

Fixed with https://github.com/qubvel/efficientnet/pull/70