I am trying to train a fully convolutional network for my problem. I am using the implementation https://github.com/shelhamer/fcn.berkeleyvision.org .
I have different image sizes.
I am not sure how to set the 'Offset' param in the 'Crop' layer.
What are the default values for the 'Offset' param?
How to use this param to crop the images around the center?
According to the Crop layer documentation, it takes two bottom blobs and outputs one top blob. Let's call the bottom blobs as A and B, the top blob as T.
A -> 32 x 3 x 224 x 224
B -> 32 x m x n x p
Then,
T -> 32 x m x n x p
Regarding axis parameter, from docs:
Takes a Blob and crop it, to the shape specified by the second input Blob, across all dimensions after the specified axis.
which means, if we set axis = 1, then it will crop dimensions 1, 2, 3. If axis = 2, then T would have been of the size 32 x 3 x n x p. You can also set axis to a negative value, such as -1, which would mean the last dimension, i.e. 3 in this case.
Regarding offset parameter, I checked out $CAFFE_ROOT/src/caffe/proto/caffe.proto (on line 630), I did not find any default value for offset parameter, so I assume that you have to provide that parameter, otherwise it will result in an error. However, I may be wrong.
Now, Caffe knows that you need a blob of size m on the first axis. We still need to tell Caffe from where to crop. That's where offset comes in. If offset is 10, then your blob of size m will be cropped starting from 10 and end at 10+m-1 (for a total of size m). Set one value for offset to crop by that amount in all the dimensions (which are determined by axis, remember? In this case 1, 2, 3). Otherwise, if you want to crop each dimension differently, you have to specify number of offsets equal to the number of dimensions being cropped (in this case 3). So to sum up all,
If you have a blob of size 32 x 3 x 224 x 224 and you want to crop a center part of size 32 x 3 x 32 x 64, then you would write the crop layer as follows:
layer {
name: "T"
type: "Crop"
bottom: "A"
bottom: "B"
top: "T"
crop_param {
axis: 2
offset: 96
offset: 80
}
}
Related
According to this, RGB triplet colors with values from 0 to 1 can be specified in Octave.
How to do that for a scatter plot of two vectors of equal length, where all points will have the same RGB color [0.5,0,0.5]?
I tried the following:
a = randn(100,1);
b = randn(100,1);
scatter(a,b,[0.5,0,0.5],'filled')
error: __scatter__: mx_el_or: nonconformant ar
guments (op1 is 100x1, op2 is 3x1)
error: called from
__scatter__ at line 52 column 7
scatter at line 86 column 10
The documentation on scatter() tells you that the syntax is scatter(x,y,s,c), i.e. x-coordinate, y-coordinate, size, colour. Size is the 1D radius of a point and thus is either a scalar, setting all points to equal size, or an array as large as x and y to set each point to an individual size. The error you get is that you specified 3 size values to 100 points.
This also directly points to the solution: you forgot an argument.Simply make all points the same size:
scatter(a,b,3,[0.5,0,0.5], 'filled')
This will give each point the size 3 and colour as specified by your RGB values.
I am trying to perform Maxpooling operation in caffe.
Input size is 6 x 6 x 1 x 1024 whereas the kernel size is 7 x 7.
Am i supposed to do padding inorder to perform MaxPooling.
First, you haven't specified the stride; the kernel dimensions are 7x7, larger than your input, but that's the size, not the stride. Stride is how far you move between iterations, such as shifting 2 pixels (which effectively halves the size of the output).
You probably want to pad so that the center of the kernel (element (3, 3) with 0-based indexing) can be over each pixel of your input. This means that you need a 3-pixel pad ( (7-1)/2 ) in each direction.
Is that what you needed?
When convolution uses a kernel size of 4 and stride size of 4, meanwhile, the input size is only 10, it will be fail when trying to do third convolution operation on the boundary of input, so, should the input padded with zeros on boundary implicitly to avoid this problem? Is there any problem when I padded with other real numbers? Is it equals to increase the input size automatically?
Besides, if I expected to get a same size output feature map, usually kernel size of 3 and pad size of 1 can be used, but when kernel size is a odd number, how to decide the pad size on each side of input?
Yes, the input must be padded with zeros to overcome the small input image size problem. To compute the output feature maps at each level use the following formula:
H_out = ( H_in + 2 x Padding_Height - Kernel_Height ) / Stride_Height + 1
W_out = (W_in + 2 x Padding_Width - Kernel_Width) / Stride_Width + 1
You may keep the padding in accordance with the above formula.
I would like to plot CSV data, and refer them with two x-axes. On the bottom linear (4*$1^2) scale, and on the top - logarithmic scale in other units ($1). Both scales should refer to the same plot.
plot "sum_no_realloc.csv" using ($1*$1*4):4 with lines,
So the bottom scale should be in 4*$1^2 units, and the top should be in $1 units.
Use the link command.
Suppose that your data file looks like this:
3 1
4 2
10 3
20 4
and you want to plot as you described. The x2 axis needs to show the x-coordinates and the x1 axis needs to show the transformed coordinates.
Issue the following commands:
set link x2 via sqrt(x/4.0) inverse 4.0*x*x
set x2tics
Then if you plot by
plot "datafile.txt" using ($1*$1*4.0):2 with lines
You will see that the x2 axis runs from 0 to 20 and the x1 axis runs from 0 to 1600 (4*20*20). The link command forces the two axes to be linked based on a mapping function. You need to specify how the x2 axis is determined from the x1 axis and how to go the other way around as well - gnuplot will usually throw a warning message when you do this about not being able to confirm the mapping.
The following plot shows the results (I labeled the axes using the normal set xlab and set x2lab commands).
I have data like this
x-axis data values
-20.49, -12.23, -9.99, -1.00 0 , 1.12, 2.23, 3.45, 4.56, 8.99, 20.99, 30.23
y-axis data values
10,20,20,40,50,60........
I would like to transform above given data into xy coordinate system.
Please have look at the image.
For eg:
along x-axis (min, max ) data value (-20.49, 30.23),
along y-axis (min, max ) data value (10,60)
now if I want plot data(-20.49, 10) in image,
the X coordinate is going to be =200,
and Y-coordinate going to be = 220.
Like this I want plot all data fits within the range of rectangle.
Hope this gives all details
Thanks
This is more of the math question, not related to any programming language. And speaking about Actionscript 3, it has Y axis going from top to bottom, not from bottom to top. Anyway: If you have two points on an axis that you want to map to screen coordinates of your choice, record xmin as lesser native value, xmax as greater native value, and coordinates as xleft and xright. Then, when you need to receive a screen coordinate for your given x, you calculate the xcoord value as:
xcoord = xleft + (x - xmin)*(xright - xleft)/(xmax - xmin);
Similar approach will net you correct values for the Y axis.