Hi,
i tried to use an existing net architecture with caffemodel, which was
trained with grayscale images ( 1 inputchannel) with my RGB-images(3
inputchannels).
Therefore i have to modify the kernels of the first layer.
The 64 kernels of the first layer are 1x3x3 tensors.
I want to replicate the 3x3-matrix, such that one kernel is 3x3x3 instead of 1x3x3.
Unfortunately i was neither able to resize conv_1_weights (ValueError: cannot resize this array: it does not own its data
) nor to use np.copy(a) (ValueError: could not broadcast input array from shape (3,3,3) into shape (1,3,3)).
import numpy as np
import caffe
net = caffe.Net('./phseg_v5.prototxt', '../../Net.caffemodel', caffe.TEST)
conv_1_weights = net.params['conv_d0a-b'][0].data
conv_1_biases = net.params['conv_d0a-b'][1].data
for i in range(conv_1_weights.shape[0]):
a = np.append(conv_1_weights[i], conv_1_weights[i], axis=0)
a = np.append(conv_1_weights[i], a, axis=0)
net.params['conv_d0a-b'][0].data[i] = np.copy(a)
Is there a way to resize the kernels, such that i get a correct .caffemodel for my purpose?
Thank you,
Martin