I am getting below error while trying to import tensorflow_hub. I have applied the already available solutions on Github or on stackoverflow and even downgraded my tesnorflow and estimator too. Still I am getting below. Can you please help ?
ImportError: cannot import name 'dnn_logit_fn_builder' from partially initialized module 'tensorflow_estimator.python.estimator.canned.dnn' (most likely due to a circular import) (C:\Users\kumar\anaconda3\lib\site-packages\tensorflow_estimator\python\estimator\canned\dnn.py)
code -
import tensorflow as tf
from tensorflow_estimator.python.estimator.canned.dnn import dnn_logit_fn_builder
import tensorflow_hub as hub
Given code worked fine with Tf v2.8 and v2.9.1
import tensorflow as tf
from tensorflow_estimator.python.estimator.canned.dnn import dnn_logit_fn_builder
import tensorflow_hub as hub
I'm implementing a UNet neural network but I'm having some issues while importing libraries. I found a solution for a couple of them, but I still have a problem with these two imports:
from tensorflow.keras.optimizers import Adam
#Import "tensorflow.keras.optimizers" could not be resolved(reportMissingImports)
from tensorflow.keras.preprocessing.image import ImageDataGenerator
#Import "tensorflow.keras.preprocessing.image" could not be resolved(reportMissingImports)
I've already imported:
import tensorflow as tf
from tensorflow import keras
from keras import layers
import tensorflow_datasets as tfds
import matplotlib.pyplot as plt
import numpy as np
Any idea? I've tried to change but it still raises an error.
when I try to import keras on a Jupyter notebook I receive this error message: ModuleNotFoundError: No module named 'tensorflow'.
I need to use keras to build an LSTM model fora project and am a beginner in python so I don't know how to get around this error. I have tried to install tenserflow and keras into an environment on anaconda but I receive the same error. For reference, I am using a Mac.
My code:
#Import libraries used
import math
import pandas as pd
import pandas_datareader.data as web
import datetime as dt
import numpy as np
from sklearn.preprocessing import MinMaxScaler
import matplotlib.pyplot as plt
from keras.models import Sequential
from keras.layers import Dense, LSTM
Any help would be greatly appreciated!
I'm hoping someone can help me. When I run the following setup I get the error below. It seems like the alibi package is causing it. The other posts related to this problem are either because of case sensitive spellings of 'DataFrame' or .py filenames.
import tensorflow as tf
tf.logging.set_verbosity(tf.logging.ERROR) # suppress deprecation messages
from tensorflow.keras import backend as K
from tensorflow.keras.layers import Dense, Input
from tensorflow.keras.models import Model, load_model
from tensorflow.keras.utils import to_categorical
import matplotlib
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import os
from sklearn.datasets import load_boston
from alibi.explainers import CounterFactualProto
AttributeError: module 'pandas' has no attribute 'DataFrame'
I'm having problem with tensorflow. I want to use ImageDataGenerator, but I'm receiving error ModuleNotFoundError: No module named 'tf'. Not sure what is the problem. I added this tf.version to test will it work, and it shows the version of tensorflow.
import tensorflow as tf
from tensorflow import keras
print(tf.__version__)
from tf.keras.preprocessing.image import ImageDataGenerator
When I run this code, I get this:
2.1.0
Traceback (most recent call last):
File "q:/TF/Kamen papir maaze/rks.py", line 14, in <module>
from tf.keras.preprocessing.image import ImageDataGenerator
ModuleNotFoundError: No module named 'tf'
The line
import tensorflow as tf
means you are importing tensorflow with an alias as tf to call it modules/functions.
You cannot use the alias to import other modules.
For your case, if you call directly
tf.keras.preprocessing.image.ImageDataGenerator(...)
then it will work.
or
you need to import the module with the right module name. i.e.
from tensorflow.keras.preprocessing.image import ImageDataGenerator
This works, tested on kaggle with tf_v2.6 and tf_v2.7
from tensorflow.keras.preprocessing.text import Tokenizer
from tensorflow.keras.preprocessing.sequence import pad_sequences
from tensorflow.keras.utils import to_categorical
from tensorflow.keras.models import Sequential
...
in Tensorflow 2.0+, to use keras instead of tf use tensorflow always-
import tensorflow
from tensorflow.keras.preprocessing.image import ImageDataGenerator