您好,请考虑以下代码:
# load the mnist training data CSV file into a list
training_data_file = open("Training_Set/mnist_train_100.csv", 'r')
training_data_list = training_data_file.readlines()
training_data_file.close()
caches_x = []
caches_y = []
for record in training_data_list:
all_values = record.split(',')
x_inputs = (np.asfarray(all_values[1:]) / 255.0 * 0.99) + 0.01
y_inputs = (np.asfarray(all_values[0]))
cache_x = (x_inputs)
caches_x.append(cache_x)
cache_y = (y_inputs)
caches_y.append(cache_y)
train_x = np.array(caches_x).T
print("shape of train_x = " + str(train_x.shape))
print("train_x =" + str(train_x))
train_y = np.array(caches_y).T
print("shape of train_y = " + str(train_y.shape))
print("train_y =" + str(train_y))
当我打印train_x的形状时,我的期望值为(784,103)。
当我打印train_y的形状时,我有(103,)
我做错了什么?同样对于train_y,我希望(或想要拥有)形状(1,103) 有人可以帮我吗? tnx。