在python形状中,返回维度,但在这段代码中,它返回的集合总数。请有人告诉我形状和shape1的工作
代码:
m_train = train_set_x_orig.shape[0]
m_test = test_set_x_orig.shape[0]
num_px = train_set_x_orig.shape[1]
print ("Number of training examples: m_train = " + str(m_train))
print ("Number of testing examples: m_test = " + str(m_test))
print ("Height/Width of each image: num_px = " + str(num_px))
print ("Each image is of size: (" + str(num_px) + ", " + str(num_px) + ", 3)")
print ("train_set_x shape: " + str(train_set_x_orig.shape))
print ("train_set_y shape: " + str(train_set_y.shape))
print ("test_set_x shape: " + str(test_set_x_orig.shape))
print ("test_set_y shape: " + str(test_set_y.shape))输出:
Number of training examples: m_train = 209
Number of testing examples: m_test = 50
Height/Width of each image: num_px = 64
Each image is of size: (64, 64, 3)
train_set_x shape: (209, 64, 64, 3)
train_set_y shape: (1, 209)
test_set_x shape: (50, 64, 64, 3)
test_set_y shape: (1, 50)发布于 2018-07-21 12:18:37
这在计算机视觉中是相当普遍的,第一维是例数,第二和第三维提供实例的数据。例如,在计算机视觉中,有一组形状(x,y)的n个图像是很常见的。在这种情况下,您的训练集将是形状(n,x,y)。数据中的第四个维度是通道的数量(本例中为3,或RGB )。
在您的数据集中,每个图像的高度和宽度是相同的,因此,仅通过第三行: num_px = train_set_x_orig.shape1就可以检索图像的大小
https://stackoverflow.com/questions/51455927
复制相似问题