You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You have to convert your input image to vec_t, i.e. std::vector<float>. When your are running OpenCV, you can convert your image as follows (I follow the conversion as used in mnist_parser.h):
float denominator = 255;
float min = -1;
float max = 1;
int padding = 2;
vec_t sample(3*H + 2*padding)*(W + 2*padding), min);
for (int i = 0; i < H; i++) { // Go over all rows
for (int j = 0; j < W; j++) { // Go over all columns
for (int c = 0; c < 3; c++) { // Go through all channels
sample[W*H*c + W*(i + padding) + (j + padding)] = image.at<cv::Vec3b>(i, j)[c]/denominator*(max - min) + min;
}
}
}
As you can see, padding is applied (I am using a kernel of size 5 x 5 in the first convolutional layer). If your kernel is of size 2_k + 1 x 2_k + 1, then you should padd the image by k on each side. Further, the image is transformed to lie in [-1,1].
No description provided.
The text was updated successfully, but these errors were encountered: