Skip to content

Instantly share code, notes, and snippets.

@manashmandal
Last active February 18, 2018 15:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save manashmandal/8e8a9db16fc64c32ac09b7a1d00ba9d7 to your computer and use it in GitHub Desktop.
Save manashmandal/8e8a9db16fc64c32ac09b7a1d00ba9d7 to your computer and use it in GitHub Desktop.
import matplotlib.pyplot as plt
import h5py
from sklearn.model_selection import train_test_split
def load():
f = h5py.File("./data/dataset.h5")
x = f['x'].value
y = f['y'].value
f.close()
x_train , x_test, y_train, y_test = train_test_split(x,y,test_size=0.2,random_state=100)
# Making the data channel last
x_train = np.rollaxis(x_train, 1, 4)
x_test = np.rollaxis(x_test, 1, 4)
# Normalizing data
x_train = x_train / 255.0
x_test = x_test / 255.0
return x_train, x_test, y_train, y_test
x_train, x_test, y_train, y_test = load()
plt.imshow(x_train[0])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment