Skip to content

Commit afff7b4

Browse files
Naruugabrieldemarmiesse
authored andcommitted
Update pooling.py (keras-team#13467)
* Update pooling.py Added Integer at the `pool_size` of `MaxPooling3D` * Update pooling.py Add Integer in `strides` and `pool_size` of 3D layers Added "If None, it will default to `pool_size`." to be consistent with explanation of 1D, 2D layer * Update pooling.py `channels_first` ->`"channels_first"` `channels_last` ->`"channels_last"` "channels_last"->`"channels_last"`
1 parent e25f68d commit afff7b4

File tree

1 file changed

+51
-49
lines changed

1 file changed

+51
-49
lines changed

keras/layers/pooling.py

+51-49
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,10 @@ class MaxPooling1D(_Pooling1D):
7676
If None, it will default to `pool_size`.
7777
padding: One of `"valid"` or `"same"` (case-insensitive).
7878
data_format: A string,
79-
one of `channels_last` (default) or `channels_first`.
79+
one of `"channels_last"` (default) or `"channels_first"`.
8080
The ordering of the dimensions in the inputs.
81-
`channels_last` corresponds to inputs with shape
82-
`(batch, steps, features)` while `channels_first`
81+
`"channels_last"` corresponds to inputs with shape
82+
`(batch, steps, features)` while `"channels_first"`
8383
corresponds to inputs with shape
8484
`(batch, features, steps)`.
8585
@@ -124,10 +124,10 @@ class AveragePooling1D(_Pooling1D):
124124
If None, it will default to `pool_size`.
125125
padding: One of `"valid"` or `"same"` (case-insensitive).
126126
data_format: A string,
127-
one of `channels_last` (default) or `channels_first`.
127+
one of `"channels_last"` (default) or `"channels_first"`.
128128
The ordering of the dimensions in the inputs.
129-
`channels_last` corresponds to inputs with shape
130-
`(batch, steps, features)` while `channels_first`
129+
`"channels_last"` corresponds to inputs with shape
130+
`(batch, steps, features)` while `"channels_first"`
131131
corresponds to inputs with shape
132132
`(batch, features, steps)`.
133133
@@ -228,15 +228,15 @@ class MaxPooling2D(_Pooling2D):
228228
If None, it will default to `pool_size`.
229229
padding: One of `"valid"` or `"same"` (case-insensitive).
230230
data_format: A string,
231-
one of `channels_last` (default) or `channels_first`.
231+
one of `"channels_last"` (default) or `"channels_first"`.
232232
The ordering of the dimensions in the inputs.
233-
`channels_last` corresponds to inputs with shape
234-
`(batch, height, width, channels)` while `channels_first`
233+
`"channels_last"` corresponds to inputs with shape
234+
`(batch, height, width, channels)` while `"channels_first"`
235235
corresponds to inputs with shape
236236
`(batch, channels, height, width)`.
237237
It defaults to the `image_data_format` value found in your
238238
Keras config file at `~/.keras/keras.json`.
239-
If you never set it, then it will be "channels_last".
239+
If you never set it, then it will be `"channels_last"`.
240240
241241
# Input shape
242242
- If `data_format='channels_last'`:
@@ -273,7 +273,7 @@ class AveragePooling2D(_Pooling2D):
273273
"""Average pooling operation for spatial data.
274274
275275
# Arguments
276-
pool_size: integer or tuple of 2 integers,
276+
pool_size: Integer or tuple of 2 integers,
277277
factors by which to downscale (vertical, horizontal).
278278
(2, 2) will halve the input in both spatial dimension.
279279
If only one integer is specified, the same window length
@@ -283,15 +283,15 @@ class AveragePooling2D(_Pooling2D):
283283
If None, it will default to `pool_size`.
284284
padding: One of `"valid"` or `"same"` (case-insensitive).
285285
data_format: A string,
286-
one of `channels_last` (default) or `channels_first`.
286+
one of `"channels_last"` (default) or `"channels_first"`.
287287
The ordering of the dimensions in the inputs.
288-
`channels_last` corresponds to inputs with shape
289-
`(batch, height, width, channels)` while `channels_first`
288+
`"channels_last"` corresponds to inputs with shape
289+
`(batch, height, width, channels)` while `"channels_first"`
290290
corresponds to inputs with shape
291291
`(batch, channels, height, width)`.
292292
It defaults to the `image_data_format` value found in your
293293
Keras config file at `~/.keras/keras.json`.
294-
If you never set it, then it will be "channels_last".
294+
If you never set it, then it will be `"channels_last"`.
295295
296296
# Input shape
297297
- If `data_format='channels_last'`:
@@ -387,21 +387,22 @@ class MaxPooling3D(_Pooling3D):
387387
"""Max pooling operation for 3D data (spatial or spatio-temporal).
388388
389389
# Arguments
390-
pool_size: tuple of 3 integers,
390+
pool_size: Integer or tuple of 3 integers,
391391
factors by which to downscale (dim1, dim2, dim3).
392392
(2, 2, 2) will halve the size of the 3D input in each dimension.
393-
strides: tuple of 3 integers, or None. Strides values.
393+
strides: Integer, tuple of 3 integers, or None. Strides values.
394+
If None, it will default to `pool_size`.
394395
padding: One of `"valid"` or `"same"` (case-insensitive).
395396
data_format: A string,
396-
one of `channels_last` (default) or `channels_first`.
397+
one of `"channels_last"` (default) or `"channels_first"`.
397398
The ordering of the dimensions in the inputs.
398-
`channels_last` corresponds to inputs with shape
399+
`"channels_last"` corresponds to inputs with shape
399400
`(batch, spatial_dim1, spatial_dim2, spatial_dim3, channels)`
400-
while `channels_first` corresponds to inputs with shape
401+
while `"channels_first"` corresponds to inputs with shape
401402
`(batch, channels, spatial_dim1, spatial_dim2, spatial_dim3)`.
402403
It defaults to the `image_data_format` value found in your
403404
Keras config file at `~/.keras/keras.json`.
404-
If you never set it, then it will be "channels_last".
405+
If you never set it, then it will be `"channels_last"`.
405406
406407
# Input shape
407408
- If `data_format='channels_last'`:
@@ -437,21 +438,22 @@ class AveragePooling3D(_Pooling3D):
437438
"""Average pooling operation for 3D data (spatial or spatio-temporal).
438439
439440
# Arguments
440-
pool_size: tuple of 3 integers,
441+
pool_size: Integer or tuple of 3 integers,
441442
factors by which to downscale (dim1, dim2, dim3).
442443
(2, 2, 2) will halve the size of the 3D input in each dimension.
443-
strides: tuple of 3 integers, or None. Strides values.
444+
strides: Integer, tuple of 3 integers, or None. Strides values.
445+
If None, it will default to `pool_size`.
444446
padding: One of `"valid"` or `"same"` (case-insensitive).
445447
data_format: A string,
446-
one of `channels_last` (default) or `channels_first`.
448+
one of `"channels_last"` (default) or `"channels_first"`.
447449
The ordering of the dimensions in the inputs.
448-
`channels_last` corresponds to inputs with shape
450+
`"channels_last"` corresponds to inputs with shape
449451
`(batch, spatial_dim1, spatial_dim2, spatial_dim3, channels)`
450-
while `channels_first` corresponds to inputs with shape
452+
while `"channels_first"` corresponds to inputs with shape
451453
`(batch, channels, spatial_dim1, spatial_dim2, spatial_dim3)`.
452454
It defaults to the `image_data_format` value found in your
453455
Keras config file at `~/.keras/keras.json`.
454-
If you never set it, then it will be "channels_last".
456+
If you never set it, then it will be `"channels_last"`.
455457
456458
# Input shape
457459
- If `data_format='channels_last'`:
@@ -513,10 +515,10 @@ class GlobalAveragePooling1D(_GlobalPooling1D):
513515
514516
# Arguments
515517
data_format: A string,
516-
one of `channels_last` (default) or `channels_first`.
518+
one of `"channels_last"` (default) or `"channels_first"`.
517519
The ordering of the dimensions in the inputs.
518-
`channels_last` corresponds to inputs with shape
519-
`(batch, steps, features)` while `channels_first`
520+
`"channels_last"` corresponds to inputs with shape
521+
`(batch, steps, features)` while `"channels_first"`
520522
corresponds to inputs with shape
521523
`(batch, features, steps)`.
522524
@@ -559,10 +561,10 @@ class GlobalMaxPooling1D(_GlobalPooling1D):
559561
560562
# Arguments
561563
data_format: A string,
562-
one of `channels_last` (default) or `channels_first`.
564+
one of `"channels_last"` (default) or `"channels_first"`.
563565
The ordering of the dimensions in the inputs.
564-
`channels_last` corresponds to inputs with shape
565-
`(batch, steps, features)` while `channels_first`
566+
`"channels_last"` corresponds to inputs with shape
567+
`(batch, steps, features)` while `"channels_first"`
566568
corresponds to inputs with shape
567569
`(batch, features, steps)`.
568570
@@ -614,15 +616,15 @@ class GlobalAveragePooling2D(_GlobalPooling2D):
614616
615617
# Arguments
616618
data_format: A string,
617-
one of `channels_last` (default) or `channels_first`.
619+
one of `"channels_last"` (default) or `"channels_first"`.
618620
The ordering of the dimensions in the inputs.
619-
`channels_last` corresponds to inputs with shape
620-
`(batch, height, width, channels)` while `channels_first`
621+
`"channels_last"` corresponds to inputs with shape
622+
`(batch, height, width, channels)` while `"channels_first"`
621623
corresponds to inputs with shape
622624
`(batch, channels, height, width)`.
623625
It defaults to the `image_data_format` value found in your
624626
Keras config file at `~/.keras/keras.json`.
625-
If you never set it, then it will be "channels_last".
627+
If you never set it, then it will be `"channels_last"`.
626628
627629
# Input shape
628630
- If `data_format='channels_last'`:
@@ -649,15 +651,15 @@ class GlobalMaxPooling2D(_GlobalPooling2D):
649651
650652
# Arguments
651653
data_format: A string,
652-
one of `channels_last` (default) or `channels_first`.
654+
one of `"channels_last"` (default) or `"channels_first"`.
653655
The ordering of the dimensions in the inputs.
654-
`channels_last` corresponds to inputs with shape
655-
`(batch, height, width, channels)` while `channels_first`
656+
`"channels_last"` corresponds to inputs with shape
657+
`(batch, height, width, channels)` while `"channels_first"`
656658
corresponds to inputs with shape
657659
`(batch, channels, height, width)`.
658660
It defaults to the `image_data_format` value found in your
659661
Keras config file at `~/.keras/keras.json`.
660-
If you never set it, then it will be "channels_last".
662+
If you never set it, then it will be `"channels_last"`.
661663
662664
# Input shape
663665
- If `data_format='channels_last'`:
@@ -709,15 +711,15 @@ class GlobalAveragePooling3D(_GlobalPooling3D):
709711
710712
# Arguments
711713
data_format: A string,
712-
one of `channels_last` (default) or `channels_first`.
714+
one of `"channels_last"` (default) or `"channels_first"`.
713715
The ordering of the dimensions in the inputs.
714-
`channels_last` corresponds to inputs with shape
716+
`"channels_last"` corresponds to inputs with shape
715717
`(batch, spatial_dim1, spatial_dim2, spatial_dim3, channels)`
716-
while `channels_first` corresponds to inputs with shape
718+
while `"channels_first"` corresponds to inputs with shape
717719
`(batch, channels, spatial_dim1, spatial_dim2, spatial_dim3)`.
718720
It defaults to the `image_data_format` value found in your
719721
Keras config file at `~/.keras/keras.json`.
720-
If you never set it, then it will be "channels_last".
722+
If you never set it, then it will be `"channels_last"`.
721723
722724
# Input shape
723725
- If `data_format='channels_last'`:
@@ -744,15 +746,15 @@ class GlobalMaxPooling3D(_GlobalPooling3D):
744746
745747
# Arguments
746748
data_format: A string,
747-
one of `channels_last` (default) or `channels_first`.
749+
one of `"channels_last"` (default) or `"channels_first"`.
748750
The ordering of the dimensions in the inputs.
749-
`channels_last` corresponds to inputs with shape
751+
`"channels_last"` corresponds to inputs with shape
750752
`(batch, spatial_dim1, spatial_dim2, spatial_dim3, channels)`
751-
while `channels_first` corresponds to inputs with shape
753+
while `"channels_first"` corresponds to inputs with shape
752754
`(batch, channels, spatial_dim1, spatial_dim2, spatial_dim3)`.
753755
It defaults to the `image_data_format` value found in your
754756
Keras config file at `~/.keras/keras.json`.
755-
If you never set it, then it will be "channels_last".
757+
If you never set it, then it will be `"channels_last"`.
756758
757759
# Input shape
758760
- If `data_format='channels_last'`:

0 commit comments

Comments
 (0)