【发布时间】:2020-05-01 21:28:28
【问题描述】:
尝试将 Tensorflow 训练的模型加载到 Deeplearning4J 中,但出现以下错误:
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
var arr: INDArray = Nd4j.create(data) //.reshape(1, -1, -1, 3);
arr = Nd4j.pile(arr, arr)
sd.associateArrayWithVariable(arr, sd.variables.get(0))
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(image, axis=0) 是什么意思
3) Deeplearning4J 重塑(1, -1, -1, 3);
【问题讨论】:
标签: numpy tensorflow reshape deeplearning4j faster-rcnn