I'm trying to balanced my data on jupyter-notebook, using SMOTE:
from imblearn import over_sampling
from imblearn.over_sampling import SMOTE
balanced = SMOTE()
x_balanced , y_balanced = balanced.fit_resample(X_train,y_train)
but I'm getting the following error on the first line -
AttributeError: module 'sklearn.metrics._dist_metrics' has no attribute 'DatasetsPair'
Why am I getting this error?
thanks.
Reinstall scikit learn to version 1.1.0. That should solve the problem
Had the same error while importing modules from skforecast package
from skforecast.model_selection import grid_search_forecaster
from skforecast.model_selection import backtesting_forecaster
Reinstalling scikit-learn to version 1.1.0 or 1.0.0 worked with additionally restarting the jupyter server.
Trying to import my train model to TensorFlow Lite fails with this error:
ImportError: cannot import name 'export_tflite_ssd_graph_lib'
What is this happening?
By following this tutorial:
https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/running_on_mobile_tensorflowlite.md
I was able to get around this issue.
Make sure you run it from
/models/research
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.
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)
When I import tensorflow
import tensorflow as tf
I don't get an error. However, I do get the error below. I'm using spyder if that helps.
As per other questions, I ensured up to date (v1.8) tensorflow using both conda and then pip installs. This didn't resolve the issue. Please assist.
import tensorflow.examples.tutorials.mnist.input_data as input_data
ModuleNotFoundError: No module named 'tensorflow.examples'
I think you should use like bellow on tensorflow 2
import tensorflow_datasets
mnist = tensorflow_datasets.load('mnist')
Use the following, it will download the data. It is from the tensorflow documentation
import tensorflow as tf
(train_images, train_labels), (test_images, test_labels) = tf.keras.datasets.mnist.load_data()
Sometimes the TensorFlow examples are not pre-downloaded, so you might need to run the below command to install the examples from Github using the below code.
!pip install -q git+https://github.com/tensorflow/examples.git
To load the mnist dataset in Tensorflow 2.0:
mnist = tf.keras.datasets.mnist
(x_train, y_train), (x_test, y_test) = mnist.load_data()
Here is the reference:
TensorFlow 2 quickstart for beginners
Another method(also works for locally saved dataset):
DATA_URL = 'https://storage.googleapis.com/tensorflow/tf-keras-datasets/mnist.npz'
path = tf.keras.utils.get_file('mnist.npz', DATA_URL)
with np.load(path) as data:
train_examples = data['x_train']
train_labels = data['y_train']
test_examples = data['x_test']
test_labels = data['y_test']
Here is the reference:
Load NumPy data
Sometimes on downloading the TF, the example directory might not be available. You could rectify it by linking the 'example' directory from the GitHub repo into the tensorflow python wheel folder. That way you don't need to change the code.
If this doesn't work, try to replace import tensorflow.examples.tutorials.mnist.input_data as input_data as import input_data as mentioned in the link:
TensorFlow MNIST example not running with fully_connected_feed.py
Hope this helps!!!
Different approach
OS: Windows
copy from:
https://github.com/tensorflow/examples/tree/master/tensorflow_examples
to
[python folder]\Lib\site-packages\tensorflow_examples
use
import tensorflow_examples
example
from tensorflow_examples.models import pix2pix
but for datasets use:
pip install tensorflow_datasets
I solved this issue by adding **tutorial** directory into tensorflow_core, usually this issue pops up when lacking of this file
..\anaconda3\envs\tensorflow\Lib\site-packages\tensorflow_core\examples check this directory to see if you have tutorials file.
lack of tutorial file
If you do not have, then go to https://github.com/tensorflow/tensorflow download the zip file, and extract all (or open it).
download tutorial file
find tutorials file from tensorflow-master\tensorflow\examples\, and copy it to ..\anaconda3\envs\tensorflow\Lib\site-packages\tensorflow_core\examples.
Issue resolved.
run
from tensorflow.examples.tutorials.mnist import input_data
import matplotlib.pyplot as plt
mnist = input_data.read_data_sets("MNIST_data", one_hot=True)
im = mnist.train.images[1]
im = im.reshape(-1, 28)
plt.imshow(im)
I solved this issue on Mac, simply copy the official examples to tensorflow_core/examples directory.
pull the tensorflow code
git clone https://github.com/tensorflow/tensorflow
copy the examples to the system python3 directory
cp -a tensorflow/examples/ /usr/local/lib/python3.7/site-packages/tensorflow_core/examples/
You need to download the data sets to use it.
Command:
pip install tensorflow-datasets
Code part:
mnist_train = tfds.load(name="mnist", split="train")
You are done now. Happy coding! :)
You just need to download the lost files and copy them to the tensorflow-core/ examples.
for me on windows 10 is :
C:\Users\Amirreza\AppData\Local\Programs\Python\Python37\Lib\site-packages\tensorflow_core\examples
This folder has been deleted at September/2020. See their repository.
I used the commands:
git clone https://github.com/tensorflow/tensorflow.git
tensorflow> git checkout c31acd156c
I solved this issue by installing Keras according to this answer from different question:
I didn't have Keras installed and had to add it manualy
ImportError: No module named 'keras'