I tried to install tensorflow_federated in google colab. I used
pip install --quiet tensorflow-federated-nightly
import tensorflow-federated as tff
and it worked. but now when I try to import it get this error:
AttributeError: module 'keras.api._v2.keras.experimental' has no attribute 'PeepholeLSTMCell'
I don't know why I get this error, because I didn't have any problem before.
I also used the following code to install tensorflow-federated:
pip install --upgrade tensorflow-federated-nightly
but I get the same error.
How do I fix it?
My versions are:
tensorflow 2.8.0,
keras 2.8.0,
tensorflow-federated-nightly 0.19.0.dev20220218
To use TensorFlow Federated with TensorFlow 2.8.0, please try the newly released version of TFF 0.20.0 pypi, github.
The tensorflow-federated-nightly package depends on the nightly versions of TensorFlow (tf-nightly), Keras (keras-nightly) and so on.
Related
I installed imageai,tensorflow,keras in python with pip
i typed this code
from imageai.Detection import ObjectDetection
it shows this error
ModuleNotFoundError: No module named 'keras.layers.advanced_activations'
module versions
imageai - 2.0.2
keras - 2.90
tensorflow - 2.9.1
im running on windows 10 pro
Try to update version of imageai to new versions.
try this
As imageai now uses Pytorch in backend, you must install a few library dependencies before installing imageai. Please refer to this link for the same.
pip install cython pillow>=7.0.0 numpy>=1.18.1 opencv-python>=4.1.2 torch>=1.9.0 --extra-index-url https://download.pytorch.org/whl/cpu torchvision>=0.10.0 --extra-index-url https://download.pytorch.org/whl/cpu pytest==7.1.3 tqdm==4.64.1 scipy>=1.7.3 matplotlib>=3.4.3 mock==4.0.3
pip install imageai --upgrade
Import the Object detection api from imageai
from imageai.Detection import ObjectDetection
Let us know if the issue still persists. Thank you.
I am trying to use tensorflow_rankings, but cannot import it due to the above error. I am using tensorflow 2.8.0 and tensorflow_rankings 0.5.0, which seem to be the latest stable builds. They are what get automatically installed from
pip install tensorflow
pip install tensorflow_ranking
I am on Python 3.8.10, Windows 11.
The TF 2.8.0 docs show there is a Normalization layer in tf.keras.layers. The error seems to come from:
from tensorflow.python.keras.layers import normalization as keras_norm
in
from tensorflow_estimator.python.estimator.canned.dnn import dnn_logit_fn_builder
Any advice?
Seems my installation of TF was corrupted. A full uninstall and reinstall fixed it.
I am using colab to train a tensorflow model. I see that google colab installs the following version by default:
import tensorflow
tensorflow.__version__
2.6.0
...
[train model]
...
model.save('mymodel.h5')
However, when I download the model to my windows pc and try to load it with tensorflow/keras, I get an error
import keras
import tensorflow
model = keras.models.load_model(r"mymodel.h5")
model_config = json.loads(model_config.decode('utf-8'))
AttributeError: 'str' object has no attribute 'decode'
After searching on the net, it appears this is due to the different tensorflow versions (colab vs. my PC).
tensorflow.__version__
Out[4]: '2.1.0'
The problem is that when I install tensorflow with conda install tensorflow-gpu this is the version I get. Even trying to force conda install tensorflow-gpu==2.6 does not install anything.
What should I do?
Thanks!
hacky solution for now...
download tensorflow 2.1 + CUDA and CuDNN using conda install tensorflow-gpu
upgrade using pip install tensorflow-gpu==2.6 --upgrade --force-reinstall
The GPU does not work (likely because the CUDA versions are not the right ones) but at least I can run a tf 2.6 script using the CPU.
Here is the cell that needs to be run before starting the tutorial.
##test {"skip": true}
# tensorflow_federated_nightly also bring in tf_nightly, which
# can causes a duplicate tensorboard install, leading to errors.
!pip uninstall --yes tensorboard tb-nightly
!pip install --quiet --upgrade tensorflow_federated_nightly
!pip install --quiet --upgrade nest_asyncio
!pip install --quiet tb-nightly # or tensorboard, but not both
import nest_asyncio
nest_asyncio.apply()
It is giving out following errors:
ERROR: tensorflow 2.4.1 requires tensorboard~=2.4, which is not installed.
ERROR: tensorflow 2.4.1 has requirement gast==0.3.3, but you'll have gast 0.4.0 which is incompatible.
ERROR: tensorflow 2.4.1 has requirement grpcio~=1.32.0, but you'll have grpcio 1.34.1 which is incompatible.
ERROR: tensorflow 2.4.1 has requirement h5py~=2.10.0, but you'll have h5py 3.1.0 which is incompatible.
ERROR: datascience 0.10.6 has requirement folium==0.2.1, but you'll have folium 0.8.3 which is incompatible.
Need help resolving this. I am not much familiar with libraries and classes on Tensorflow.
Even though the console says there was an error, the pip packages should have been installed correctly.
This happens because the notebooks use tensorflow-federated-nightly, which depends on an installs tf-nightly overwriting the base tensorflow install. However pip still thinks the TFF dependencies will conflict with the now overwritten TensorFlow core package.
Adding tensorflow to the !pip uninstall list may make this error go away, but the functionality of the notebook won't change.
You can import tensorflow federated like the following. It solved my error. I tried to follow Federated Learning for Image Classification and while I was trying to import tensorflow_federated it was always giving me error.
from tensorflow_federated import python as tff
I'm trying to run object detection API's object_detection_tutorial.ipynb and I was able to run it before and i trained some simple models for object detection. I think broke my installation. I'm using Anaconda+Windows and Tensorflow 1.4 installed on an environment called "neuralnets" here is pip list of this environment:
pip list
error:
error
if in your Python console you type:
import tensorflow as tf
tf.__Version__
What do you get? just to make sure try to reinstall with the --ignore-installed flag:
pip install --ignore-installed tensorflow=1.4