tensorflow 2.0, tfds.load 'utf-8' codec error - tensorflow2.x

Imports & Settings
%matplotlib inline
from pathlib import Path
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib.ticker import FuncFormatter
import seaborn as sns
import tensorflow as tf
from tensorflow.keras.applications.densenet import DenseNet201
from tensorflow.keras.layers import Dense, BatchNormalization
from tensorflow.keras.models import Sequential
from tensorflow.keras.callbacks import ModelCheckpoint, EarlyStopping
from tensorflow.keras.regularizers import l1_l2
from tensorflow.keras.optimizers import Adam
import tensorflow_datasets as tfds
Load EuroSat Dataset
(raw_train, raw_validation), metadata = tfds.load('eurosat',
split=['train[:90%]','train[90%:]'],
with_info=True,
shuffle_files=False,
as_supervised=True,
data_dir='../data/tensorflow')
i got error message
how can i fix it?
i use tensorflow2
I guess there's a problem with the codec.

Related

how to import the libraries of toimage in scipy.misc?

import matplotlib.pyplot as plt
import cv2
from scipy.misc import toimage
im = toimage(skeleton)
cv2.imwrite('./zee/img'+(str(count)+".png"),im)
but we get
ImportError: cannot import name 'toimage'

How can I solve this problem in vs code, ipython (tensorflow)?

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import check_util.checker as checker
from IPython.display import clear_output
from PIL import Image
import os
import time
import re
from glob import glob
import shutil
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
import tensorflow as tf
from tensorflow import keras
from tensorflow.keras import layers
from tensorflow import keras
print('tensorflow version: {}'.format(tf.__version__))
print('GPU available: {}'.format(tf.test.is_gpu_available()))
When I run this, there is no error. But it shows as indefinitely in progress.
(Current 630..631..632...sec)

No OUTPUT from Jupyter Notebook. NO Error Shown

I am running a Jupyter notebook but I do not get any output or error telling me if something is wrong. I have tried installing tornado as some other threads have suggested as well as the command pip install notebook --upgrade
While I do not think there is a problem with my code here it is.
Any help is truly appreciated.
import os
import numpy as np
import pandas as pd
import cv2
from glob import glob
import tensorflow as tf
from tensorflow.keras.layers import *
from tensorflow.keras.applications import MobileNetV2
from tensorflow.keras.callbacks import ModelCheckpoint, ReduceLROnPlateau
from tensorflow.keras.optimizers import Adam
from sklearn.model_selection import train_test_split
if __name__=="_main_":
path="dog-breed-identification/"
train_path = os.path.join(path, "train/*")
train_path = os.path.join(path, "test/*")
train_path = os.path.join(path, "labels.csv")
labels_df = pd.read_csv(labels_path)
#name of column in csv
breed = labels_df["breed"].unique()
print("Number of Breed: ", len(breed))
enter code here
As it turns out, if I delete
if __name__=="_main_":
I get an output

ImportError: cannnot import name 'Imputer' from 'sklearn.preprocessing'

Trying to import Imputer from sklearn.preprocessing,
import pandas as pd
dataset = pd.read_csv('Data.csv')
X = dataset.iloc[:, :-1].values
y = dataset.iloc[:, 3].values
#PART WHERE ERROR OCCURS:-
from sklearn.preprocessing import Imputer
Shows "ImportError: cannot import name 'Imputer' from 'sklearn.preprocessing' (/home/codeknight13/anaconda3/lib/python3.7/site-packages/sklearn/preprocessing/_init_.py)"
from sklearn.preprocessing import Imputer was deprecated with scikit-learn v0.20.4 and removed as of v0.22.2. See the sklean changelog.
from sklearn.impute import SimpleImputer
import numpy as np
imputer = SimpleImputer(missing_values=np.nan, strategy='mean')
pip install scikit-learn==0.20.4 or conda install scikit-learn=0.20.4 are not a good options because scikit-learn==0.20.4 is more than 3 years out of date.

How to scale a data using Python 3

I am trying to scale my data using Python 3
But I keep getting this error: I am out of ideas as to what could be the issue? Please can you assist me guys? I would deeply appreciate your help!
import pandas as pd
import numpy as np
from numpy.random import randn
from pandas import Series, DataFrame
from pandas.plotting import scatter_matrix
import matplotlib as mpl
import matplotlib.pyplot as plt
from matplotlib import rcParams
from pylab import rcParams
import seaborn as sb
import scipy
from scipy import stats
from scipy.stats import pearsonr
from scipy.stats import spearmanr
from scipy.stats import chi2_contingency
import sklearn
from sklearn import preprocessing
from sklearn.preprocessing import scale
mtcars = pd.read_csv('mtcars.csv')
mtcars.columns = ['Car
names','mpg','cyl','disp','hp','drat','wt','qsec','vs','am','gear','carb']
mpg = mtcars['mpg']
#Scale your data
mpg_matrix = mpg.reshape(-1,1)
scaled = preprocessing.MinMaxScaler()
scaled_mpg = scaled.fit_transform(mpg_matrix)
plt.plot(scaled_mpg)
plt.show()
mpg_matrix = mpg.numpy.reshape(-1,1)
tr__
File "C:\Anaconda\lib\site-packages\pandas\core\generic.py", line 5067, in __getattr__
return object.__getattribute__(self, name)
AttributeError: 'Series' object has no attribute 'numpy'
pandas.core.series.Series doesn't have reshape.
Perhaps:
mpg_matrix = mpg.values.reshape(-1,1)
i.e. get the underlying numpy array and reshape that.

Resources