我正在尝试使用 caffe-tensorflow 将 caffe 模型转换为 tensorflow 模型。
我收到以下错误
ValueError:无法将大小为 0 的数组重塑为形状 (16,3,3,3)'
抛出错误的方法:
def normalize_pb_data(self, layer):
transformed = []
for blob in layer.blobs:
print('layer name - %s %d' % (layer.name,len(blob.shape.dim)) )
if len(blob.shape.dim):
dims = blob.shape.dim
c_o, c_i, h, w = map(int, [1] * (4 - len(dims)) + list(dims))
else:
c_o = blob.num
c_i = blob.channels
h = blob.height
w = blob.width
if layer.name != "data/bias":
data = numpy.array(blob.data, dtype=np.float32).reshape(c_o, c_i, h, w)
transformed.append(data)
return transformed
来自原始文本的图层信息:
layer {
name: "conv1"
type: "Convolution"
bottom: "data/bias"
top: "conv1"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 2
decay_mult: 0
}
convolution_param {
num_output: 16
bias_term: true
pad: 0
kernel_size: 3
group: 1
stride: 1
weight_filler {
type: "msra"
}
bias_filler {
type: "constant"
value: 0
}
dilation: 1
}
}