Problems when using load function of Tensorflow Datasets - python

I am trying to load a Dataset from Tensorflow Datasets API, but it doesn't work.
The error is the following:
AttributeError: module 'tensorflow._api.v2.compat.v2.compat' has no attribute 'v1'
I have no idea what the cause could be, anyone any ideas?
Tensorflow Version: 2.0.0-beta1
tfds Version: 2.0.0
Thanks in advance
import tensorflow as tf
import tensorflow_datasets as tfds
dataset, metadata = tfds.load(name="cycle_gan/horse2zebra", with_info=True, as_supervised=True)

Related

cannot import name 'binary_weighted_focal_crossentropy' from 'keras.backend'

im trying to import categorical_dqn
when i try the following
from tf_agents.agents.categorical_dqn import categorical_dqn_agent
i get
ImportError: cannot import name 'binary_weighted_focal_crossentropy' from 'keras.backend' (C:\Users\tgmjack\anaconda3\lib\site-packages\keras\backend.py)
the advice i find around the internet Error importing binary_weighted_focal_crossentropy from keras backend: Cannot import name is to try importing this stuff first
from tensorflow import keras
from tensorflow.keras import layers
from tensorflow.keras.metrics import binary_focal_crossentropy
i end up with the exact same error caused by the second line of this suggestion however.
ImportError: cannot import name 'binary_weighted_focal_crossentropy' from 'keras.backend' (C:\Users\tgmjack\anaconda3\lib\site-packages\keras\backend.py)
####### bonus info ########
im running all this on anaconda
tensorflow version = 2.9.2
tf agents version = 0.5.0
keras version = 2.9.0
im trying to follow this tutorial = https://github.com/tensorflow/agents/blob/master/docs/tutorials/9_c51_tutorial.ipynb
I had a similar problem with tf_agents a few months ago. Doing this fixed it for me:
pip install tf-agents[reverb]
I have the following packages with their respective versions:
keras 2.9.0
tensorflow 2.9.2
tf-agents 0.13.0

UnicodeDecodeError from Tensorflow Tutorials "Text classification with TF Hub"

I just start learning tensorflow with Tutorials of Tensorflow Core.
import os
import numpy as np
import tensorflow as tf
import tensorflow_hub as hub
import tensorflow_datasets as tfds
train_data, validation_data, test_data = tfds.load(name='imdb_reviews', split=('train[:60%]', 'train[60%:]', 'test'), as_supervised=True)
then I got error like this.
error messages
Some blog says this Error can be resolved by installing tensorflow-gpu.
But in my case, that dosen't work.
How can I fix this error?
(win10, anaconda. conda ver. 4.9.2., windows terminal, anaconda prompt)
After re-installation of Anaconda and Tensorflow issue was resolved.
import os
import numpy as np
import tensorflow as tf
import tensorflow_hub as hub
import tensorflow_datasets as tfds
train_data, validation_data, test_data = tfds.load(name='imdb_reviews', split=('train[:60%]', 'train[60%:]', 'test'), as_supervised=True)

AttributeError: module 'tensorflow_datasets.text' has no attribute 'YelpPolarityReviews'

I am trying to download a TensorFlow dataset yelp polarity reviews
In order to do this I am doing the following command:
tfds.text.YelpPolarityReviews
But this return the following error:
AttributeError: module 'tensorflow_datasets.text' has no attribute
'YelpPolarityReviews'
After this I triyed to download the hole datasets of the following way:
import tensorflow_datasets.download.DownloadManager as dl_manager
train_dir = dl_manager.download_and_extract('https://s3.amazonaws.com/fast-ai-nlp/yelp_review_polarity_csv.tgz')
But this doesn't work and I get the following error:
ModuleNotFoundError: No module named 'tensorflow_datasets.download'
The question is how can I download that dataset in order to use it with TensorFlow?
Thanks
The dataset is yelp_polarity_reviews, you have to add the underscore and make sure everything is in small. Can you try this out and see if it works?
!pip install tensorflow-datasets
import tensorflow as tf
import tensorflow_datasets as tfds
data = tfds.load('yelp_polarity_reviews', split='train', shuffle_files=True)

Keras Import Error when loading a pre trained model

I am trying to use a pre-trained model in Tensorflow. I am using the following code:
import tensorflow as tf
from tensorflow import keras
from keras.applications import mobilenet_v2
I get the following error:
ModuleNotFoundError: No module named 'keras'
However, the following codes do work:
from tensorflow.keras.applications import mobilenet_v2
OR
from keras_applications import mobilenet_v2
The 2 methods mentioned above work but the 1st one doesn't. Why does this happen?
I've solved this problem by downgrading tensorflow to version 2.0 using this command:
pip install tensorflow==2.0
I hope it helps you.

keras error : Mnist on keras isnt working for me

i tried this code
from keras.datasets import mnist
from keras.models import Sequential
from keras.layers import Dense
import tensorflow as tf
mnist = tf.keras.datasets.mnist
print("gud to go")
(training, newtraining)= mnist.load_data()
and this error showed
https://hastebin.com/eridajexev.sql
i have tried upgrading it and tensorflow but it shows error ,may be post how to do that ,that may work
help please?
edit:
im using version 1.9.0 of tensorflow
edit2 :
i used pip3 install --upgrade tensorflow==1.10.0 and still no and note that ,im using python3

Categories

Resources