Skip to content

Commit

Permalink
add raises in tf_backend docstrings` (keras-team#5144)
Browse files Browse the repository at this point in the history
  • Loading branch information
keunwoochoi authored and fchollet committed Jan 23, 2017
1 parent c751f81 commit d739b3c
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions keras/backend/tensorflow_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ def learning_phase():
def set_learning_phase(value):
"""Sets the learning phase to a fixed value,
either 0 or 1 (integers).
# Raises
ValueError: if `value` is neither `0` nor `1`.
"""
global _GRAPH_LEARNING_PHASES
if value not in {0, 1}:
Expand Down Expand Up @@ -1460,6 +1463,9 @@ def resize_images(X, height_factor, width_factor, dim_ordering):
# Returns
A tensor.
# Raises
ValueError: if `dim_ordering` is neither `tf` or `th`.
"""
if dim_ordering == 'th':
original_shape = int_shape(X)
Expand Down Expand Up @@ -1492,6 +1498,9 @@ def resize_volumes(X, depth_factor, height_factor, width_factor, dim_ordering):
# Returns
A tensor.
# Raises
ValueError: if `dim_ordering` is neither `tf` or `th`.
"""
if dim_ordering == 'th':
output = repeat_elements(X, depth_factor, axis=2)
Expand Down Expand Up @@ -1645,6 +1654,9 @@ def spatial_2d_padding(x, padding=(1, 1), dim_ordering='default'):
# Returns
A padded 4D tensor.
# Raises
ValueError: if `dim_ordering` is neither `tf` or `th`.
"""
if dim_ordering == 'default':
dim_ordering = image_dim_ordering()
Expand All @@ -1670,6 +1682,9 @@ def asymmetric_spatial_2d_padding(x, top_pad=1, bottom_pad=1,
# Returns
A padded 4D tensor.
# Raises
ValueError: if `dim_ordering` is neither `tf` or `th`.
"""
if dim_ordering == 'default':
dim_ordering = image_dim_ordering()
Expand Down Expand Up @@ -1698,6 +1713,10 @@ def spatial_3d_padding(x, padding=(1, 1, 1), dim_ordering='default'):
# Returns
A padded 5D tensor.
# Raises
ValueError: if `dim_ordering` is neither `tf` or `th`.
"""
if dim_ordering == 'default':
dim_ordering = image_dim_ordering()
Expand Down Expand Up @@ -1979,6 +1998,12 @@ def rnn(step_function, inputs, initial_states,
at time `t` for sample `s`.
new_states: list of tensors, latest states returned by
the step function, of shape `(samples, ...)`.
# Raises
ValueError: if input dimension is less than 3.
ValueError: if `unroll` is `True` but input timestep is not a fixed number.
ValueError: if `mask` is provided (not `None`) but states is not provided
(`len(states)` == 0).
"""
ndim = len(inputs.get_shape())
if ndim < 3:
Expand Down Expand Up @@ -2616,6 +2641,9 @@ def conv2d(x, kernel, strides=(1, 1), border_mode='valid',
# Returns
A tensor, result of 2D convolution.
# Raises
ValueError: if `dim_ordering` is neither `tf` or `th`.
"""
if dim_ordering == 'default':
dim_ordering = image_dim_ordering()
Expand Down Expand Up @@ -2653,6 +2681,9 @@ def deconv2d(x, kernel, output_shape, strides=(1, 1),
# Returns
A tensor, result of transposed 2D convolution.
# Raises
ValueError: if `dim_ordering` is neither `tf` or `th`.
"""
if dim_ordering == 'default':
dim_ordering = image_dim_ordering()
Expand Down Expand Up @@ -2690,6 +2721,9 @@ def atrous_conv2d(x, kernel, rate=1,
# Returns
A tensor, result of atrous transposed 2D convolution.
# Raises
ValueError: if `dim_ordering` is neither `tf` or `th`.
"""
if dim_ordering == 'default':
dim_ordering = image_dim_ordering()
Expand All @@ -2710,6 +2744,9 @@ def atrous_conv2d(x, kernel, rate=1,
def separable_conv2d(x, depthwise_kernel, pointwise_kernel, strides=(1, 1),
border_mode='valid', dim_ordering='default'):
"""2-D convolution with separable filters.
# Raises
ValueError: if `dim_ordering` is neither `tf` or `th`.
"""
if dim_ordering == 'default':
dim_ordering = image_dim_ordering()
Expand Down Expand Up @@ -2744,6 +2781,9 @@ def conv3d(x, kernel, strides=(1, 1, 1),
# Returns
A tensor, result of 3D convolution.
# Raises
ValueError: if `dim_ordering` is neither `tf` or `th`.
"""
if dim_ordering == 'default':
dim_ordering = image_dim_ordering()
Expand Down Expand Up @@ -2773,6 +2813,10 @@ def pool2d(x, pool_size, strides=(1, 1),
# Returns
A tensor, result of 2D pooling.
# Raises
ValueError: if `dim_ordering` is neither `tf` or `th`.
ValueError: if `pool_mode` is neither `max` or `avg`.
"""
if dim_ordering == 'default':
dim_ordering = image_dim_ordering()
Expand Down Expand Up @@ -2808,6 +2852,10 @@ def pool3d(x, pool_size, strides=(1, 1, 1), border_mode='valid',
# Returns
A tensor, result of 3D pooling.
# Raises
ValueError: if `dim_ordering` is neither `tf` or `th`.
ValueError: if `pool_mode` is neither `max` or `avg`.
"""
if dim_ordering == 'default':
dim_ordering = image_dim_ordering()
Expand Down

0 comments on commit d739b3c

Please sign in to comment.