ImportError: cannot import name 'convert_kernel' - python

When i try to use tensorflow to train model, i get this error message.
File "/Users/ABC/anaconda3/lib/python3.6/site-packages/keras/utils/layer_utils.py", line 7, in
from .conv_utils import convert_kernel
ImportError: cannot import name 'convert_kernel'
i have already install Keras

I got the same issue. The filename of my python code was "tensorflow.py". After I changed the name to "test.py". The issue was resolved.
I guess there is already a "tensorflow.py" in the tensorflow package. If anyone uses the same name, it may lead to the conflict.
If your python code is also called "tensorflow.py", you can try to use other names and see if it helps.

Related

ImportError: cannot import name 'EXTRACTOR_FILENAME' from 'talon.signature'

I am having trouble getting an import statement to work. I am attempting to use this package:
https://github.com/mailgun/talon
I am running the following command:
from talon.signature import EXTRACTOR_FILENAME, EXTRACTOR_DATA
I get the following error:
ImportError: cannot import name 'EXTRACTOR_FILENAME' from 'talon.signature' (system path to file)
While troubleshooting I don't see EXTRACTOR_FILENAME or EXTRACTOR_DATA defined anywhere. I did a search in directory for all files. Is there some sort of convention in python where EXTRACTOR_FILENAME maps to a specific class?
UPDATE: Figured it out, just something as simple as manually defining the 2 constants. The docs weren't exactly clear or I missed it.
For your project the import looks like this:
import talon
from talon import quotations
Put those statements on the top of your file, and it should work.
if you don't have the packages on your system type this in your terminal:
pip install talon
The Github repo also explains this

ImportError: cannot import name 'TwitterPreprocessor' from 'preprocessor'

I am installing the package for data-cleaning purpose,
!pip install tweet-preprocessor
from preprocessor import TwitterPreprocessor
I am using both Jupyter and Colab, there is no issue using in Jupyter. But still, receiving this issue in colab:
ImportError: cannot import name 'TwitterPreprocessor' from 'preprocessor' (/usr/local/lib/python3.7/dist-packages/preprocessor/init.py)
Please help me with this problem to correct.
Thank you
The library tweet-preprocessor simply doesn't have the TwitterPreprocessor you're trying to import. Take a look at the GitHub repo - no TwitterPreprocessor in sight.
It's suggested to import it via: import preprocessor as p (or import one of the said names from the GitHub repo). You can look at the __init__.py what names you're able to import.
ImportError: cannot import name 'TwitterPreprocessor' from 'preprocessor' ([...]\preprocessor\_init_.py)

ModuleNotFoundError: No module named 'mxnet.contrib.amp' When importing gluonnlp

I have the following versions of mxnet==1.4.0 and gluonnlp==0.9.1 installed using pip.
However when I run the following codeimport gluonnlp as nlp it yields the following error
ModuleNotFoundError: No module named 'mxnet.contrib.amp'
So I try to manually import the missing module using
from mxnet.contrib import amp
import gluonnlp as nlp
which also yields an error
ImportError: cannot import name 'amp' from 'mxnet.contrib' (/usr/local/lib/python3.7/dist-packages/mxnet/contrib/__init__.py)
I've been running the code on Colab. Is there a possible workaround for this issue?
Please Advise.
I have not used these libraries but in this github issue they say:
AMP was introduced in MXNet 1.5. Could you try that version (or newer)?
So I think that the problem is there.
Cheers!

Tensorflow: AttributeError: module 'tensorflow.python' has no attribute 'control_flow_ops'

I'm using keras ver 1.0.8 and tensorflow ver 0.12.0.
I ran python image_zooms_training.py -n 0
then it throws
`AttributeError: module 'tensorflow.python' has no attribute 'control_flow_ops'
please tell me how to solve . thank you for your help.
Following import works. You need to update that line
from tensorflow.python.ops import control_flow_ops
Official TensorFlow Support discourages use of tf.python.* as it is private and intended for development purposes only. While it may work in some cases, it will "break unannounced" in many others.
Instead, try importing tensorflow with the .python portion removed, e.g.:
from tensorflow.keras.models import Sequential

TensorFlow MNIST example not running with fully_connected_feed.py

I am able to run the Deep MNIST Example fine, but when running fully_connected_feed.py, I am getting the following error:
File "fully_connected_feed.py", line 19, in <module>
from tensorflow.g3doc.tutorials.mnist import input_data ImportError: No module named
g3doc.tutorials.mnist
I am new to Python so could also just be a general setup problem.
This is a Python path issue. Assuming that the directory tensorflow/g3doc/tutorials/mnist is your current working directory (or in your Python path), the easiest way to resolve it is to change the following lines in fully_connected_feed.py from:
from tensorflow.g3doc.tutorials.mnist import input_data
from tensorflow.g3doc.tutorials.mnist import mnist
...to:
import input_data
import mnist
Another alternative is to link the 'g3doc' directory from the github repo into the tensorflow python wheel folder. That way you don't need to change the code.

Categories

Resources