I am following the article https://www.analyticsvidhya.com/blog/2018/10/predicting-stock-price-machine-learningnd-deep-learning-techniques-python/ . After copy and paste the following code:
#importing required libraries
from sklearn.preprocessing import MinMaxScaler
from keras.models import Sequential
from keras.layers import Dense, Dropout, LSTM
#creating dataframe
data = df.sort_index(ascending=True, axis=0)
new_data = pd.DataFrame(index=range(0,len(df)),columns=['Date', 'Close'])
for i in range(0,len(data)):
new_data['Date'][i] = data['Date'][i]
new_data['Close'][i] = data['Close'][i]
...
I get an error: "No module named 'keras'. I search online and find I need to install keras module. In the article https://github.com/antoniosehk/keras-tensorflow-windows-installation , there is a step-by-step guide on how to install keras. However, it requires Nvida graphic card for GPU while I only have an integrated Intel graphic card. Therefore, I try to find another link at https://software.intel.com/en-us/articles/intel-optimization-for-tensorflow-installation-guide that works for Intel graphic card, so I install tensorflow as follows:
conda install tensorflow-mkl
During the installation, I can see one package is called keras-xxx, so I belive keras is also installed. But after the installation, when I try to run the code, I still get the error. Why?
Thanks
If you have CUDA supports GPU (NVIDEA Series), I strongly recommend you to install tensorflow-gpu from the aconda forge by conda command (not by pip) because the tensorflow-gpu needs a lot of requirments such as CUDA, CuDNN and etc that caused too hard to configurate all together correctly. if use the conda all the packages install together easily (without any tears!!!)
conda install -c anaconda tensorflow-gpu
but if you want to use cpu, you can easily install tensorflow by the pip or conda
Related
So this is my error [ModuleNotFoundError: No module named 'tensorflow.contrib']
I'm using tensorflow 2.0.0 and python 3.6.9 when i downgrade the tensorflow version of the code doesn't work when i upgrade it the same thing happens . (i am using jupyter notebook)
I tried to downgrade tensorflow's version and vice versa .
This is the part of the code where i have the error
Please help i really can't find a solution.
tensorflow.contrib is being removed in version 2.0, you therefore need version <= 1.14 to operate tflearn.
In the command line (not the notebook), conda install tensorflow=1.14 (or tensorflow-gpu=1.14 if you want GPU support ; or pip install rather than conda install depending on what you are used to do).
tensorflow.contrib is being removed in version 2.0, you therefore need version <= 1.14 to operate tflearn (by the way, this is a TFlearn issue, not a tensorflow one).
In your case, I would consider moving to tensorflow (instead of tflearn) and using the tf.keras API, which provides the higher-level API tflearn aimed at offering in times when tf.keras was not out yet.
this:
import tensorflow as tf
from transformers import BertTokenizer, TFBertForSequenceClassification
model = TFBertForSequenceClassification.from_pretrained("bert-base-uncased")
Outputs the following error:
ImportError:
TFBertForSequenceClassification requires the TensorFlow library but it was not found in your environment. Checkout the instructions on the
installation page: https://www.tensorflow.org/install and follow the ones that match your environment.
However it's not true I don't have the TensorFlow library imported.
> print(tf.__version__)
'2.7.0'
As this is to answer the question when Tensorflow is indeed installed and imported this can often be a problem in this case.
BERT requires the tensorflow-gpu package so you need to have installed the tensorflow-gpu package to do what you are attempting here.
IF you are in a notebook run:
!pip install tensorflow-gpu
Otherwise on the command line run:
pip install tensorflow-gpu
Hope this is helpful to others out there facing issues!
import tensorflow as tf
from transformers import BertTokenizer, TFBertForSequenceClassification
Worked with
Tensorflow-2.7.0
huggingface-hub-0.2.1
tokenizers-0.10.3
transformers-4.15.0
Python-3.7
Install Tensorflow and Transformers
!pip install tensorflow
!pip install transformers
I believe you are on MacOS. If so, installing the latest version of transformers (v4.21.1) should fix this issue. (I am also running M1 pro, if that helps).
For me the latest update was giving an error with incompatible checkpoint weight files, so I had to install transformers v4.2.2 which gave me the above error.
To fix it, you need to do an editable install: https://huggingface.co/docs/transformers/installation#installing-from-source
i.e.
git clone https://github.com/huggingface/transformers.git
cd transformers
pip install -e .
Before running the above code, make the following changes:
In transformers/setup.py Line 134, change to "tokenizers==0.6.0"
In transformers/src/transformers/file_utils.py Line 87, change "tensorflow" to "tensorflow-macos"
Finally, in transformers/src/transformers/dependency_versions_check.py comment out Line 41 ("# require_version_core(deps[pkg])"
For the final step, upgrade the tokenizers library to a newer version (say 0.12.1). You cant have the newer tokenizers library before installing the transformers package - it fails to build the wheel.
Reference: https://id2thomas.medium.com/apple-silicon-experiment-1-installing-huggingface-transformers-2e45392d3d0f
https://github.com/apple/tensorflow_macos/issues/144
Transformers requires Tensorflow version >= 2.3
To see the installed Tensorflow version, run the python script below:
import tensorflow as tf
print(tf.__version__)
If tensorflow version is actually too low, you may upgrade it.
For Tensorflow of CPU version,
run the command in a notebook,
!pip install tensorflow>=2.3
or run the command in a command window:
pip install tensorflow>=2.3
For Tensorflow of GPU version,
run the command in a notebook,
!pip install tensorflow-gpu>=2.3
or run the command in a command window,
pip install tensorflow-gpu>=2.3
I am trying to run MPL Neural Network using the scikit-learn library running on Jupyter Notebook. However, I have been trying to import the MPLClassifier but failed. I also have tried solution from here, SKlearn import MLPClassifier fails. I followed the steps and installed everything but could not import the module from SKlearn which are,
Installed the SKlearn using pip install scikit-neuralnetwork
Installed the mingw package using conda install mingw libpython and conda install -c free mingw, as the package is not available when using https://jmeubank.github.io/tdm-gcc/
Checked its availability using conda list
It is giving the following error,
cannot import name 'MPLClassifier' from 'sklearn.neural_network'
May I get help on other alternatives to import the module?
I'm using python 3.8.2 , keras 2.3.1 and tensorflow 2.2.0rc4 .
just with the following code :
import keras
from keras.models import sequential
I have this error :
AttributeError: partially initialized module 'keras.backend' has no attribute 'eager' (most likely due to a circular import)
if I use :
import tensorflow
or
from tensorflow.keras import ....
new error :
AttributeError: partially initialized module 'tensorflow.python.framework.ops' has no attribute 'register_tensor_conversion_function' (most likely due to a circular import)
full traceback:
enter image description here
enter image description here
My suggestion is to reinstall the package. Sometimes this happens due to the installation problem.
Use the following code to do so
Uninstall tensorflow
pip uninstall tensorflow
Requires the latest pip
pip install --upgrade pip
To install keras as separate package
pip install Keras
Current stable release for CPU and GPU
pip install tensorflow
Try this and hope this helps you.
It's an install problem, most likely; K.eager was introduced in Keras 2.3.0 (and is included in Keras 2.3.1), so your Python interpreter is somehow reading code of 2.2.5 or earlier.
A possible culprit is an Anaconda mishap. First run conda uninstall keras. Then, in the anaconda3 directory, search "keras" and delete all results. Lastly, run conda install -c conda-forge keras, which should download version 2.3.1. You might need to run similar steps with TensorFlow (in fact, it's better you do, and first reinstall TensorFlow then Keras).
P.S., your code is probably from keras import Sequential, as sequential should error differently.
I am working in anaconda environment
I used conda install tensorflow to install tensorflow
In the code I :
import tensorflow as tf
from tensorflow.python.data import Dataset
The first command passes but the second command does not (Import error)
I looked In the github of tensorflow and saw that the tensorflow.python.data module exists but probably changed
Is there a way to get Dataset class from the anaconda installation?
If not is there a workaround ?
Ilan
My mistake was that i used :
conda install tensorflow
rather than follow the instructions in the tensorflow site
Ilan