What does the subsample
do in this function of keras
?
Convolution2D(nb_filter, nb_row, nb_col,
subsample=subsample,
activation=activation,
border_mode=border_mode,
W_regularizer=W_regularizer,
b_regularizer=b_regularizer,
dim_ordering=dim_ordering)(x)
How can implement this subsample
in tensorflow
?
subsample in Keras is the same as strides in tensorflow. You can use the strides argument in the tensorflow tf.nn.conv2d() function to implement this.
Subsample / strides tells you how much to move the filter in each dimension as you perform the convolution. For instance with a stride of 1 in each direction you would shift the filter by one for each convolution and produce an output of the same size as the input (except for border padding effects). If strides was set to 2 the dimensions of the result would be half that of the original image.
There are different ways to do subsampling. You could do average pooling, where you take the average of a patch, or max pooling, the latter being the more popular. Use tf.nn.avg_pool() or tf.nn.max_pool(), the documentation for these functions could be found here
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