Numpy 理解Tensorflow目标检测模型的阵列维数重塑

Numpy 理解Tensorflow目标检测模型的阵列维数重塑,numpy,tensorflow,reshape,deeplearning4j,faster-rcnn,Numpy,Tensorflow,Reshape,Deeplearning4j,Faster Rcnn,尝试将Tensorflow训练模型加载到DeepLearning 4J中,出现以下错误: IllegalStateException: Invalid array shape: cannot associate an array with shape [38880] with a placeholder of shape [-1, -1, -1, 3]:shape is wrong rank or does not match on one or more dimensions Python模

尝试将Tensorflow训练模型加载到DeepLearning 4J中,出现以下错误:

IllegalStateException: Invalid array shape: cannot associate an array with shape [38880] with a placeholder of shape [-1, -1, -1, 3]:shape is wrong rank or does not match on one or more dimensions
Python模型的加载方式如下:

# Load image using OpenCV and
# expand image dimensions to have shape: [1, None, None, 3]
# i.e. a single-column array, where each item in the column has the pixel RGB value
image = cv2.imread(PATH_TO_IMAGE)
image_expanded = np.expand_dims(image, axis=0)
如果您知道以下任何问题,请解释:

1) 就Python数组而言,[1,None,None,3]意味着什么

2) 在Python中,np.expand_dims(图像,轴=0)是什么意思


3) 深度学习4J整形(1,-1,-1,3)

这里混合了两个不同的概念,TF占位符和命令式numpy-like重塑

在您的例子中,模型需要4D输入张量,形状为[-1,-1,3]。对于人类来说,它可以翻译成[任何,任何,任何,3]。但是你试图用形状为[38880]的张量,秩为1的张量来填充它

现在谈谈你的问题

1) 见上文-1被视为“任何”

2) 此函数将1添加为维度。i、 e.如果您有[38880],则在轴=0处展开_dims将使其成为[13880]

3) 不,那是错的。你不应该把它当作你的形状。这里有一些图像,因此应该指定图像的适当尺寸,即[1800,600,3]

# Load image using OpenCV and
# expand image dimensions to have shape: [1, None, None, 3]
# i.e. a single-column array, where each item in the column has the pixel RGB value
image = cv2.imread(PATH_TO_IMAGE)
image_expanded = np.expand_dims(image, axis=0)