tutorials 로 가져오기

from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets("mnist_data", one_hot=True)

img_train, lbl_train = mnist.train.next_batch(batch_size)
img_test , lbl_test  = mnist.test.next_batch(mnist.test.num_examples)

 

keras로 가져오기

from keras.datasets import mnist

(train_img, train_lbl), (test_img, test_lbl) = mnist.load_data()
print (train_img.shape, train_lbl.shape,test_img.shape, test_lbl.shape)
train_img = train_img.reshape(-1,28,28,1).astype(np.float32)
test_img  = test_img.reshape(-1,28,28,1).astype(np.float32)
train_lbl = np_utils.to_categorical(train_lbl)
test_lbl  = np_utils.to_categorical(test_lbl)

pandas로 가져오기

data = pd.read_csv('https://raw.githubusercontent.com/DA4BAM/dataset/master/diamonds.csv'
                 , sep=',', skipinitialspace=True)  


df = pd.read_csv('data-diabetes.csv', delimiter=',',index_col=False)
df.head()
x_data = df.iloc[:,0:-1]
y_data = df.iloc[:,-1]
print (x_data.shape, y_data.shape)

'도서관 I > AI' 카테고리의 다른 글

Fashion-MNIST 예제  (0) 2020.06.01
기본 keras 사용법  (0) 2020.06.01
top_K  (0) 2020.06.01
softmax keras  (0) 2020.05.29
python 정리  (0) 2020.05.28

+ Recent posts