I know if I have the input layer as follows, my network will take in blobs of dimension (1,1,100,100).
layer {
name: "data"
type: "Input"
top: "data"
input_param {
shape {
dim: 1
dim: 1
dim: 100
dim: 100
}
}
}
What should I do to make the first dimension (input batch size) variable? so that I can feed in the network batches of different sizes?
You can reshape the network before calling the forward() method. So if you want a variable batch_size, you should reshape the everytime. This can be done in any interface you are using (C, python, MATLAB).
In python, it goes like this:
net.blobs['data'].reshape(BATCH_SIZE, CHANNELS, HEIGHT, WIDTH)
net.reshape()
net.forward()
hint: I believe net.reshape() is optional and the network calls this before executing the forward action.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With