Documentation required: explain all the numbers #5758

Closed
spodzone opened this Issue Mar 14, 2017 · 3 comments

Comments

Projects
None yet
2 participants
@spodzone

I'm relatively new to Keras - have had some simple Dense() networks working previously but on using it to explore CNNs I find the documentation intractable.

Please can we have one webpage that lists the meaning of all the parameters:
samples
channels
nb_filter
filter_length
batch_size
input_shape

and in particular, the relationships of requirements between them all with examples of how one should reshape a 2D numpy array to make it suitable?

I have managed to create a 1-layer CNN that does something but a) I can't be confident what it does and b) having fudged the nb_filter parameter to make it work as the first layer, attempts to daisy-chain a second layer give shape mismatch errors. To debug this, I need a simple page that explains the terms Keras uses.

Thanks

@abhaikollara

This comment has been minimized.

Show comment
Hide comment
@abhaikollara

abhaikollara Mar 14, 2017

Contributor

Hi, let me try and help

  • samples : Usually equal to your batch_size. It is the number of samples on which you're convolving at a time.
  • channels : For RGB images of size row x column the pixel values would of dimensions 3 x row x column. Each of the 3 for each channel - R, G, B
  • nb_filters : A single convolution of a filter over the image produces a single feature map. You can choose to have nb_filters number of filters producing that many feature maps
  • filter_length : In 2D conv, your filter size had 2 dimensions, determined by nb_row and nb_col. In 1D conv your filter size has 1 dimension determined by filter_length
  • batch_size : Not exactly sure where you came across it in the docs, but it generally means the number of samples in your batch of training examples.
  • input_shape : It's the shape of the input to a layer without the dimension containing number of samples. If your mini batch contains 64 28x28 RGB images, your input_shape would be (3, 28, 28) or (28, 28, 3) depending on your dim_ordering

Hope it helps

P.S Keras-2 contains some major API changes, which means many of the terms above will be deprecated. Keep yourself updated. Cheers !

Contributor

abhaikollara commented Mar 14, 2017

Hi, let me try and help

  • samples : Usually equal to your batch_size. It is the number of samples on which you're convolving at a time.
  • channels : For RGB images of size row x column the pixel values would of dimensions 3 x row x column. Each of the 3 for each channel - R, G, B
  • nb_filters : A single convolution of a filter over the image produces a single feature map. You can choose to have nb_filters number of filters producing that many feature maps
  • filter_length : In 2D conv, your filter size had 2 dimensions, determined by nb_row and nb_col. In 1D conv your filter size has 1 dimension determined by filter_length
  • batch_size : Not exactly sure where you came across it in the docs, but it generally means the number of samples in your batch of training examples.
  • input_shape : It's the shape of the input to a layer without the dimension containing number of samples. If your mini batch contains 64 28x28 RGB images, your input_shape would be (3, 28, 28) or (28, 28, 3) depending on your dim_ordering

Hope it helps

P.S Keras-2 contains some major API changes, which means many of the terms above will be deprecated. Keep yourself updated. Cheers !

@spodzone

This comment has been minimized.

Show comment
Hide comment
@spodzone

spodzone Mar 14, 2017

Thanks. That is a start. Here's my background.

Essentially I'm trying to teach myself CNNs by reimplementing Google's RAISR. In my mind the idea is to create two versions of an image, one as-is and one that's been down to half-size and upscaled back again so the CNN learns how to remove the artifacts of upscaling (replace Lanczos's errors with pixels from an existing image model). This all happens in greyscale only.

I'm splitting an image into windows nominally 64x64 px (subject to change) and choosing the ones with greatest standard deviation, in order to bias learning toward edge/sharpness/features rather than smooth areas. Because of the fixed size I can stack them vertically into something 64 px wide by however many long I like (multiple of 64). This way I can train off multiple images if I want, too - it just becomes an even longer column of boxes.

So far I've got all this happening with opencv and numpy and am happy.

It's just the Keras bits that are confusing me somewhat. What is a "sample" in this context? Should I reshape my input to match Keras's expectations and if so, how?

The plan is to use multiple Convolution2D layers, perhaps with pooling (or maybe not): atm I can only get at most one layer to work if I set nb_filter=1 at the moment; attempts to add further layers, for which I thought Keras was meant to work out tensor shapes for itself, doesn't seem to work. Obviously my fault somewhere, but... see why I would really appreciate a page documenting these terms so I can learn-through-docs-and-doing? :)

Thanks

Thanks. That is a start. Here's my background.

Essentially I'm trying to teach myself CNNs by reimplementing Google's RAISR. In my mind the idea is to create two versions of an image, one as-is and one that's been down to half-size and upscaled back again so the CNN learns how to remove the artifacts of upscaling (replace Lanczos's errors with pixels from an existing image model). This all happens in greyscale only.

I'm splitting an image into windows nominally 64x64 px (subject to change) and choosing the ones with greatest standard deviation, in order to bias learning toward edge/sharpness/features rather than smooth areas. Because of the fixed size I can stack them vertically into something 64 px wide by however many long I like (multiple of 64). This way I can train off multiple images if I want, too - it just becomes an even longer column of boxes.

So far I've got all this happening with opencv and numpy and am happy.

It's just the Keras bits that are confusing me somewhat. What is a "sample" in this context? Should I reshape my input to match Keras's expectations and if so, how?

The plan is to use multiple Convolution2D layers, perhaps with pooling (or maybe not): atm I can only get at most one layer to work if I set nb_filter=1 at the moment; attempts to add further layers, for which I thought Keras was meant to work out tensor shapes for itself, doesn't seem to work. Obviously my fault somewhere, but... see why I would really appreciate a page documenting these terms so I can learn-through-docs-and-doing? :)

Thanks

@stale stale bot added the stale label Jun 13, 2017

@stale

This comment has been minimized.

Show comment
Hide comment
@stale

stale bot Jun 13, 2017

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 30 days if no further activity occurs, but feel free to re-open a closed issue if needed.

stale bot commented Jun 13, 2017

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 30 days if no further activity occurs, but feel free to re-open a closed issue if needed.

@stale stale bot closed this Jul 13, 2017

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