Error using tensorflowjs_converter (ImportError: cannot import name model_fn)

1,072 views
Skip to first unread message

Ernesto Laval

unread,
Feb 24, 2019, 7:01:03 AM2/24/19
to TensorFlow.js Discussion
I am getting an error when using tensorflowjs_converter (it was working 2 weeks ago)

In a colab noteboook (colab.research.google.com) I do:

!pip install tensorflowjs
(No error)

And then

!tensorflowjs_converter 

And I get

Using TensorFlow backend. Traceback (most recent call last): File "/usr/local/bin/tensorflowjs_converter", line 6, in <module> from tensorflowjs.converters.converter import main File "/usr/local/lib/python2.7/dist-packages/tensorflowjs/__init__.py", line 21, in <module> from tensorflowjs import converters File "/usr/local/lib/python2.7/dist-packages/tensorflowjs/converters/__init__.py", line 24, in <module> from tensorflowjs.converters.tf_saved_model_conversion import convert_tf_saved_model File "/usr/local/lib/python2.7/dist-packages/tensorflowjs/converters/tf_saved_model_conversion.py", line 32, in <module> from tensorflow.python.tools import freeze_graph File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/tools/freeze_graph.py", line 57, in <module> from tensorflow.python.tools import saved_model_utils File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/tools/saved_model_utils.py", line 21, in <module> from tensorflow.contrib.saved_model.python.saved_model import reader File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/__init__.py", line 48, in <module> from tensorflow.contrib import distribute File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/distribute/__init__.py", line 34, in <module> from tensorflow.contrib.distribute.python.tpu_strategy import TPUStrategy File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/distribute/python/tpu_strategy.py", line 27, in <module> from tensorflow.contrib.tpu.python.ops import tpu_ops File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/tpu/__init__.py", line 73, in <module> from tensorflow.contrib.tpu.python.tpu.keras_support import tpu_model as keras_to_tpu_model File "/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/tpu/python/tpu/keras_support.py", line 71, in <module> from tensorflow.python.estimator import model_fn as model_fn_lib ImportError: cannot import name model_fn

It fails with different combinations of parameters & options.

I would appreciate any help/hint to make get this working!!

Thanks

Shanqing Cai

unread,
Feb 24, 2019, 9:26:43 AM2/24/19
to Ernesto Laval, TensorFlow.js Discussion
(Responding to the question here instead of on StackOverflow because it looks like
a potential bug and will require some back-and-forth communication.)

1. Can you find out the version of the following and let us know? 
  - tensorflow
  - keras
2. Can you try creating a clean vritualenv or pyenv and install tensorflowjs again in it?


--
You received this message because you are subscribed to the Google Groups "TensorFlow.js Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tfjs+uns...@tensorflow.org.
Visit this group at https://groups.google.com/a/tensorflow.org/group/tfjs/.
To view this discussion on the web visit https://groups.google.com/a/tensorflow.org/d/msgid/tfjs/52ec114b-1cf7-47ba-b3f5-686298925b03%40tensorflow.org.


--
---
Shanqing Cai
Software Engineer
Google

Ernesto Laval

unread,
Feb 24, 2019, 9:22:30 PM2/24/19
to TensorFlow.js Discussion, ernest...@gmail.com
output of 
!pip list | grep tensorflow
is
mesh-tensorflow 0.0.5 tensorflow 1.12.0 tensorflow-estimator 1.13.0rc0 tensorflow-hub 0.1.1 tensorflow-metadata 0.9.0 tensorflow-probability 0.5.0 tensorflowjs 0.8.0

output of 
!python -c 'import keras; print(keras.__version__)'
is
Using TensorFlow backend. 2.2.2

A while ago, when I tried in a new colab notebook, tensorflowjs_converter did work, but after importing some dependencies (e.g. import tensorflow as tf)and running some code, I got the ImportError again.


Ernesto Laval

unread,
Feb 25, 2019, 11:10:21 AM2/25/19
to TensorFlow.js Discussion

I have just noticed that this fails when I am using a runtime with Python2. With Python3 it seems to work
Reply all
Reply to author
Forward
0 new messages