I am trying to import skflow on my Windows PC. I have already install and used Anaconda on Python (3.5). I have no trouble to use tensorflow but when I want to use skflow I get the error:
ImportError Traceback (most recent call last)
<ipython-input-1-04faecc7c0de> in <module>()
8 import tensorflow as tf
9 from tensorflow.contrib import learn
---> 10 from tensorflow.contrib import skflow
ImportError: cannot import name 'skflow'
Does anyone know how to fix this?
Thanks in advance!
Please try this:
>>> import tensorflow as tf
>>> from tensorflow.contrib import learn as skflow
FYI, skflow is not any special package/module/... It's an alias for tensorflow.contrib.learn which is in 'sklearn' style.
Related
I'm try learning TensorFlow but i have a problem. I'm importing TensorFlow like in official website but i take a error.
import pandas as pd
import numpy as np
import tensorflow as tf
from tensorflow import keras
from tensorflow.keras import layers
Traceback (most recent call last):
File "C:\Users\Koray\Desktop\Python\main.py", line 4, in
from tensorflow import keras
ImportError: cannot import name 'keras' from 'tensorflow'
(C:\Users\Koray\Desktop\Python\tensorflow.py)
For community benefit, adding #John Gordon answer here in the answer section.
Don't name your script tensorflow.py. Your import finds that script instead of the real one.
Instead you can name any other for example learning.py. Now all your imports work as expected.
import pandas as pd
import numpy as np
import tensorflow as tf
from tensorflow import keras
from tensorflow.keras import layers
I'm working on google colab , and I want to import preprocess_input from tensorflow.keras.preprocessing but this error keeps occurring , while whatever I import from tensorflow work fine except this .
well i'm using tensorflow = 2.8.0
my code :
from tensorflow.keras.preprocessing import preprocess_input
the error :
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-2569fd104ea5> in <module>()
----> 1 from tensorflow.keras.preprocessing import preprocess_input
ImportError: cannot import name 'preprocess_input' from 'tensorflow.keras.preprocessing' (/usr/local/lib/python3.7/dist-packages/keras/api/_v2/keras/preprocessing/__init__.py)
---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.
To view examples of installing some common dependencies, click the
"Open Examples" button below.
---------------------------------------------------------------------------
what should I install or change to fix this error , i just want to use preprocess_input for model predicting purposes that's all , any suggestions please !
!pip install gluonts
!pip install atspy
!pip install gluonts
from gluonts.mx.trainer import Trainer
from mxnet import gluon
from gluonts.trainer import Trainer
from atspy import AutomatedModel
However, it gives me an error:
ModuleNotFoundError Traceback (most recent call
last) in
4 from gluonts.mx.trainer import Trainer
5 from mxnet import gluon
----> 6 from gluonts.trainer import Trainer
7 from atspy import AutomatedModel
ModuleNotFoundError: No module named 'gluonts.trainer'
I have no ideas how to solve this. If anyone has any ideas
In the source code, I couldn't find gluonts.trainer either. Are you sure that you need line 6?
In my case, from gluonts.mx.trainer import Trainer was sufficient. (though I only needed to use gluonts once).
I have been running several deep learning models in google colab using Keras.
My codes worked perfectly but suddenly, today, a lot of errors appeared reporting problemas with the imports. Pasting one here.
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-3-745bb0894037> in <module>()
19 from keras.preprocessing.image import ImageDataGenerator
20 from keras.utils import np_utils
---> 21 from keras_contrib.applications.densenet import DenseNetFCN
22 from keras_contrib.losses.jaccard import jaccard_distance
1 frames
/usr/local/lib/python3.7/dist-packages/keras_contrib/applications/densenet.py in <module>()
66 from keras.layers import BatchNormalization
67 from keras.regularizers import l2
---> 68 from keras.utils.layer_utils import convert_all_kernels_in_model
69 from keras.utils.data_utils import get_file
70 from keras.engine.topology import get_source_inputs
ImportError: cannot import name 'convert_all_kernels_in_model' from 'keras.utils.layer_utils' (/usr/local/lib/python3.7/dist-packages/keras/utils/layer_utils.py)
so I am answering my question for anyone who might have trouble with it.
They updated Tensorflow and Keras in Colab to 2.5 versions, and some functions are not migrated (i.e. convert_all_kernels_in_model).
For me, the solution was to paste the code of the NN architecture and comment the line with that function as I was not using it.
I know it is not the best solution but it got me through what I needed.
The final release of TensorFlow version 2.5 requires a nightly dev build of keras that seems to be the source of these issues.
https://github.com/tensorflow/tensorflow/blob/v2.5.0/tensorflow/tools/pip_package/setup.py#L107
The relevant TensorFlow issue to report your experience is:
https://github.com/tensorflow/tensorflow/issues/49823
I am trying to use the sklearn.qda package in python. I have installed it successfully but when Itry to import it I get the error message below. Can anybody tell me what should I do to fix this?
In [3]: from sklearn.qda import QDA
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-3-7d7abf937d66> in <module>()
----> 1 from sklearn.qda import QDA
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/sklearn/qda.py in <module>()
12
13 from .base import BaseEstimator, ClassifierMixin
---> 14 from .utils.fixes import unique
15 from .utils import check_arrays, array2d
16
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/sklearn/utils/__init__.py in <module>()
7 import warnings
8
----> 9 from .murmurhash import murmurhash3_32
10 from .validation import (as_float_array, check_arrays, safe_asarray,
11 assert_all_finite, array2d, atleast2d_or_csc,
ImportError: cannot import name murmurhash3_32
I had the same problem, I run:
sudo pip install -U scikit-learn
and now everything is working fine
I started a new shell and this problem went away
I faced the similar situation of getting mumurhash error while installing sklearn.preprocessing library.
I upgraded numpy version from 1.13 to 1.15
using
pip install --upgrade numpy
After this, I was able to import the sklearn library.
I fixed this by upgrading murmurhash to 1.0.5.
I faced a similar problem, so there are mainly two solutions
Either run it in administrator mode and install all the libraries and run in admin mode. Something that I would not recommend
Use virtualenv to install the libraries again and run your command in the virtualenv. This worked for me.
Hope this helps