-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d082648
commit 1e9b70b
Showing
2 changed files
with
25 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import tensorflow as tf | ||
import numpy as np | ||
import pandas as pd | ||
import matplotlib.pyplot as plt | ||
import tensorflow_datasets as tfds | ||
|
||
def load_cats_dogs(): | ||
dataset = tfds.load('cats_vs_dogs', split = 'train', shuffle_files=True) | ||
|
||
def resize(item): | ||
return tf.image.resize(item['image'], (128,128)), item['label'] | ||
|
||
dataset = dataset.map(resize) | ||
|
||
x_train = [] | ||
y_train = [] | ||
for item in tfds.as_numpy(dataset): | ||
x_train.append(np.expand_dims(item[0], axis = 0)) | ||
y_train.append(item[1]) | ||
|
||
x_train = np.concatenate(x_train, axis = 0) | ||
y_train = np.array(y_train).reshape(-1,1) | ||
|
||
x_train = x_train / 127.5 - 1 | ||
return x_train[0:20000], y_train[0:20000], x_train[20000:], y_train[20000:] |