I am using Google Colab. The link for the project is here: https://colab.research.google.com/drive/1K8aaNq5ZTXQM1zzhaWICuuY5nA06Qn7z?usp=sharing
The error:
I am learning from a course I found online on https://www.udemy.com/. I do not not know much about tensorflow and I don't know why I am getting this error. You may take a look inside the project and help me find out what I am doing wrong here.
Google Colab specifies
We recommend against using pip install to specify a particular TensorFlow version for both GPU and TPU backends.
You can read it here
So I would suggest you directly import dependencies for the project.
import numpy as np
import datetime
import tensorflow as tf
from tensorflow.keras.datasets import fashion_mnist
tf.__version__
gives output
2.3.0
this might not be directly a solution to your issue but seems worth noting. When I tried your notebook I had an issue importing 'export_saved_model'.
The solution to that seems to be here on this github repo:
https://github.com/tensorflow/models/issues/8450
Also, maybe worth noting is that you dont need to install tensorflow into colab as per this tutorial:
https://colab.research.google.com/notebooks/tensorflow_version.ipynb
Hope this helps. Good luck on your course.
Related
My problem could be potentially related to this:
Python 3.7.8 Imports an uninstalled Tensorflow Version
I am trying to test some conditions in my code on conditions when it fails to import tensorflow.
So I uninstalled tensorflow using pip uninstall (which successfully ended without error) and tried to run the code again. The problem is it still can import tensorflow from somewhere!
The 'fake' tensorflow loaded does not have any functions it should have, so basically the only thing that works is
import tensorflow
print(tensorflow.__file__)
This returns None, so I cannot even find where it is loading this thing from. Even .__version__ tells me there is no such function.
Has anyone experienced this? What can I do to solve this?
Thank you!
I am trying to use from summarizer import Summarizer, TransformerSummarizer (a.k.a. bert-extractive-summarizer) library in python to do text summerization with models like Bert, Gpt-2 and others...
But when I try this import I get an error (ie. warning but I can't run my code):
UserWarning: "sox" backend is being deprecated. The default backend will be changed to "sox_io" backend in 0.8.0 and "sox" backend will be removed in 0.9.0. Please migrate to "sox_io" backend. Please refer to https://github.com/pytorch/audio/issues/903 for the detail.
warnings.warn(
then traceback and at the end this:
AttributeError: module transformers.models.cpm has no attribute CpmTokenizer
Who can I fix this?
PS: I saw on the github that the solution to torchaudio problem is to use torchaudio.set_audio_backend("sox_io") , but how should I use it is not clarified if anyone knows the solution to the problem let them write a detailed step by step process.
I would suggest installing package tensorflow-gpu before importing any transformers library, as it internally checks if TensorFlow is installed.
pip install tensorflow-gpu
more information on how to install Tensorflow with GPU on Tensorflow
This issue was raised before as well but the problem persists for me. I am trying to build a
training detector model using tensorflow. I will tell whatever I have tried so far :
Replacing tf.contrib with TPUStrategy. Any suggestions on applying this feature on my code will be
grateful. (https://github.com/tensorflow/tensorflow/issues/26513)
Tried installing pycocotools for model_main.py
Instead of "import tensorflow as tf" tried "import tensorflow.compat.v1 as tf"
Tried replacing "contrib" with "experimental"
Tried installing tensorflow addons
As per the release notes https://github.com/tensorflow/tensorflow/releases/tag/v2.0.0-alpha0 , it says
tf.contrib has been deprecated, and functionality has been either migrated to the core TensorFlow API, to tensorflow/addons or removed entirely.
If it is migrated to tensorflow addons, which addon is it?
I've tried almost everything.
Tensorflow Version: 2.0
Getting error in the line:
slim_example_decoder = tf.contrib.slim.tfexample_decoder
Can anyone provide me with any alternative?
tensorflow.contrib does not exist anymore. Any code that relies on it is obsolete and needs to be updated (and this is no trivial task).
As of now, the tensorflow object detection API still does not support Tensorflow 2.0, because most of the models in the API are built with TF Slim, which was part of contrib an has been dropped. There is an external package for slim, but AFAIK that's not officially supported (and it's a temporary solution, at best).
Until the object detection API supports TF2, your quickest solution is to downgrade your tensorflow to 1.15.
I would like to move some of my code to tensorflow distributions and am working through the tutorials on colab. After requesting tensorflow version 2.x on the runtime, the official sample code no longer works.
You can find the colab notebook here, I added the following code at the very beginning:
try:
# %tensorflow_version only exists in Colab.
%tensorflow_version 2.x
except Exception:
pass
I've only ran the code on colab, but I don't think that it's specific to it. If you want to try to reproduce the problem on your local tensorflow installation, this should be the relevant code:
import tensorflow as tf
import tensorflow_probability as tfp
tfd = tfp.distributions
nd = tfd.MultivariateNormalDiag(loc=[0., 10.], scale_diag=[1., 4.])
nd.sample()
The last line, sampling from nd, creates the following error message:
TypeError: Tensor is unhashable if Tensor equality is enabled. Instead, use tensor.experimental_ref() as the key.
Tensorflow probability is version 0.7.0 and tensorflow is version 2.0.0.
Oh, just after posting I found this issue: https://github.com/tensorflow/probability/issues/540
The problem is fixed by installing a newer version of tensorflow probability.
In colab that can be done by executing:
!pip install tensorflow-probability==0.8.0rc0
and then restarting the runtime.
I also checked the local machine here and it has tensorflow-probability 0.8.0. But if you try to install that in colab, it complains about some dependency mismatch. I guess this whole problem will fix itself soon though, when Google rolls out the up-to-date releases of their libraries in these tutorial notebooks.
My keras.json has backend specified to be tensorflow and if I open Spyder and Jupyter IDE then tensorflow is used as a backend.
Strangely if I open python or ipython shell within my WinPython installation, the backend defaults into theano. Has anyone seen this behaviour before and if so what was the solution?
I have tried playing with environment variables to no effect.
Looks like existing notebooks still say Theano. But If I create new one and enter the following then I get proper result as tensorflow
import os
os.environ['KERAS_BACKEND']='tensorflow'
import keras
keras.backend.backend()
Using TensorFlow backend.
Out[1]:
'tensorflow'
In [ ]:
I have exactly same issue. Some how after I installed shell kernel Ipython/Jupyter is pointing properly to tensor flow
import os
os.environ['KERAS_BACKEND']='tensorflow'
import keras
keras.backend.backend()