Skip to content

Conversation

@qbetterk
Copy link

No description provided.

for (int32_cuda q = 0; q < num_col_blocks; q++) {
dst[index] = fmax(
src[index_src + p * src_stride * d.rows + q * d.cols],
dst[index]);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't you need to initialize dst[index]?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but dst is one of the input.
I am not sure how should initialize it?
I just imitate the function "_add_mat_blocks" in this file(line 722).

src[index_src + p * src_stride * d.cols + q * d.rows],
dst[index]);
}
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need alpha in these functions?
You can modify functions by removing alpha.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I would delete all the alpha.
I was not sure if we need this parameter and since the default value is one, it seems has no impact.

dst_index = i + j * dst_dim.stride,
src_index = src_i + src_j * src_dim.stride;
if (i < dst_dim.cols && j < dst_dim.rows)
dst[dst_index] += alpha * src[src_index];
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to modify this line.

void cudaF_max_mat_blocks(dim3 Gr, dim3 Bl, float alpha, const float* src,
int32_cuda num_row_blocks, int32_cuda num_col_blocks,
float* dst, MatrixDim d, int src_stride,
int A_trans) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need for alpha

void AddMatBlocks(Real alpha, const CuMatrixBase<Real> &A,
MatrixTransposeType trans = kNoTrans);

void MaxMatBlocks(Real alpha, const CuMatrixBase<Real> &A,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add comments containing function and parameter definition

// loop over all the elements in each pool to find the maximum one,
// and record its index.

for (int32_cuda t = 0; t < pool_t_size_; t++) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think your assumption in this function is that stride in all dimensions are 1.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean I should set all the stride as 1?
the stride is represented by pool_{t,h,f}_step. I would add some description.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pool_{t,h,f}_step is the stride between blocks, but as far as I found out the stride within block is 1.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean it is possible that I need to get the maximum of part of the block rather than the whole block?
Like getting 5 from block [1,6,5,7,1] with within_block_stride as 2.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean the rows of block can be something like [1 5 9]!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see what you mean, I would fix this! Thank you!
By the way, is this kind of stride only apply for rows? would the column also be like [1 5 9]?

/// function set all the values in &out_deriv whose index is not in
/// vector(not corresponding to maximum value in each pool of &in_value)
/// as zero, and keeps those correponding to maximum value as the *in_deriv.
void MaxMatBlocks(const CuMatrixBase<Real> &A, CuVectorBase<Real> &index_max_,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add description for all variables and explain how you select pooling block w.r.t parameters (You can add formula)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added the description of variables, but these descriptions are almost the same as in the file nnet-convolution-component.h(line 400), I am not sure if we should write it again.

MaxPoolingOverBlock component was firstly used in ConvNet for selecting an
representative activation in an area. It inspired Maxout nonlinearity.
Each output element of this component is the maximum of a block of
input elements where the block has a 2.5D dimension (pool_t_size_,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove 2.5D dimension and just explain block!
remove 'for selecting an representative activation in an area'


This component is designed to be used after a ConvolutionComponent
so that the input matrix is propagated from a 2d-convolutional layer.
This component implements 2.5d-maxpooling which performs
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2.5d is meaningless! You can say it is 3D-maxpooling and explain how the 3d matrix is stored in 2 dim!

@pegahgh
Copy link
Owner

pegahgh commented May 7, 2018

@qbetterk , please add test code for your function in cu-matrix.*/

@pegahgh
Copy link
Owner

pegahgh commented May 15, 2018

@qbetterk Did you add test code for max function in matrix class?

@qbetterk
Copy link
Author

qbetterk commented May 15, 2018 via email

@pegahgh
Copy link
Owner

pegahgh commented May 17, 2018

Sure, we can discuss about it when you are back!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants