Tensorflow进行训练数据测试

时间:2020-03-27 15:44:35

标签: python tensorflow

我是一个乞讨者,请不要太笨拙,我只想学习。

函数

tf.keras.datasets.mnist.load_data()

返回

Tuple of Numpy arrays: (x_train, y_train), (x_test, y_test).

但是我想要一个这样的数据集(x,y),其中$ x $是数据,$ y $是标签。这是我的尝试:

import tensorflow as tf
(x_train, y_train), (x_test, y_test) = tf.keras.datasets.mnist.load_data()
N = np.size(x_train)

training_data = []
for i in range(N):
    training_data.append( (x_train[i], y_train[i]) )

n = np.size(x_test)
test_data =  np.zeros( (n,2) )
for i in range(n):
    test_data[i] = (X_test[i],y_test[i])


net = Network([784, 30, 10])
net.SGD(training_data, 30, 10, 3.0, test_data=test_data)

我得到的错误我不明白:

training_data.append( (x_train[i], y_train[i]) ) IndexError: index 60000 is out of bounds for axis 0 with size 60000

感谢您的帮助。

0 个答案:

没有答案