I was going through CNN's and found that padding argument should be set to "Valid" if i need no padding and "Same" if i need padding. But, it doesn't make any sense to me. Why can't keras development team just put "Padding = True", is there a specific reason to choose this convention?


1 Answer 1


Using valid will essentially use as much of your input as possible, such that the dimensions continue to work. This means there is a chance some input will be trimmed (removed).

same on the other hand, will add padding to allow e.g. the number of filters/convolutions you specify to be applied.

The reason not to simply have padding=True as an option, is that there are more than two options (see snippet from the docs below). Also, that would not be very explicit: using same or valid makes it crystal clear, what the result should be using the given approach.

This is what the documentation says:

  • padding: One of "valid", "causal" or "same" (case-insensitive). "valid" means "no padding". "same" results in padding the input such that the output has the same length as the original input

Take a look at this nice answer with a simple example.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.