add raises in tf_backend docstrings` (#5144)

This commit is contained in:
Keunwoo Choi 2017-01-23 23:16:21 +00:00 committed by François Chollet
parent c751f81d0d
commit d739b3c2cd

@ -77,6 +77,9 @@ def learning_phase():
def set_learning_phase(value): def set_learning_phase(value):
"""Sets the learning phase to a fixed value, """Sets the learning phase to a fixed value,
either 0 or 1 (integers). either 0 or 1 (integers).
# Raises
ValueError: if `value` is neither `0` nor `1`.
""" """
global _GRAPH_LEARNING_PHASES global _GRAPH_LEARNING_PHASES
if value not in {0, 1}: if value not in {0, 1}:
@ -1460,6 +1463,9 @@ def resize_images(X, height_factor, width_factor, dim_ordering):
# Returns # Returns
A tensor. A tensor.
# Raises
ValueError: if `dim_ordering` is neither `tf` or `th`.
""" """
if dim_ordering == 'th': if dim_ordering == 'th':
original_shape = int_shape(X) original_shape = int_shape(X)
@ -1492,6 +1498,9 @@ def resize_volumes(X, depth_factor, height_factor, width_factor, dim_ordering):
# Returns # Returns
A tensor. A tensor.
# Raises
ValueError: if `dim_ordering` is neither `tf` or `th`.
""" """
if dim_ordering == 'th': if dim_ordering == 'th':
output = repeat_elements(X, depth_factor, axis=2) output = repeat_elements(X, depth_factor, axis=2)
@ -1645,6 +1654,9 @@ def spatial_2d_padding(x, padding=(1, 1), dim_ordering='default'):
# Returns # Returns
A padded 4D tensor. A padded 4D tensor.
# Raises
ValueError: if `dim_ordering` is neither `tf` or `th`.
""" """
if dim_ordering == 'default': if dim_ordering == 'default':
dim_ordering = image_dim_ordering() dim_ordering = image_dim_ordering()
@ -1670,6 +1682,9 @@ def asymmetric_spatial_2d_padding(x, top_pad=1, bottom_pad=1,
# Returns # Returns
A padded 4D tensor. A padded 4D tensor.
# Raises
ValueError: if `dim_ordering` is neither `tf` or `th`.
""" """
if dim_ordering == 'default': if dim_ordering == 'default':
dim_ordering = image_dim_ordering() dim_ordering = image_dim_ordering()
@ -1698,6 +1713,10 @@ def spatial_3d_padding(x, padding=(1, 1, 1), dim_ordering='default'):
# Returns # Returns
A padded 5D tensor. A padded 5D tensor.
# Raises
ValueError: if `dim_ordering` is neither `tf` or `th`.
""" """
if dim_ordering == 'default': if dim_ordering == 'default':
dim_ordering = image_dim_ordering() dim_ordering = image_dim_ordering()
@ -1979,6 +1998,12 @@ def rnn(step_function, inputs, initial_states,
at time `t` for sample `s`. at time `t` for sample `s`.
new_states: list of tensors, latest states returned by new_states: list of tensors, latest states returned by
the step function, of shape `(samples, ...)`. 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()) ndim = len(inputs.get_shape())
if ndim < 3: if ndim < 3:
@ -2616,6 +2641,9 @@ def conv2d(x, kernel, strides=(1, 1), border_mode='valid',
# Returns # Returns
A tensor, result of 2D convolution. A tensor, result of 2D convolution.
# Raises
ValueError: if `dim_ordering` is neither `tf` or `th`.
""" """
if dim_ordering == 'default': if dim_ordering == 'default':
dim_ordering = image_dim_ordering() dim_ordering = image_dim_ordering()
@ -2653,6 +2681,9 @@ def deconv2d(x, kernel, output_shape, strides=(1, 1),
# Returns # Returns
A tensor, result of transposed 2D convolution. A tensor, result of transposed 2D convolution.
# Raises
ValueError: if `dim_ordering` is neither `tf` or `th`.
""" """
if dim_ordering == 'default': if dim_ordering == 'default':
dim_ordering = image_dim_ordering() dim_ordering = image_dim_ordering()
@ -2690,6 +2721,9 @@ def atrous_conv2d(x, kernel, rate=1,
# Returns # Returns
A tensor, result of atrous transposed 2D convolution. A tensor, result of atrous transposed 2D convolution.
# Raises
ValueError: if `dim_ordering` is neither `tf` or `th`.
""" """
if dim_ordering == 'default': if dim_ordering == 'default':
dim_ordering = image_dim_ordering() dim_ordering = image_dim_ordering()
@ -2710,6 +2744,9 @@ def atrous_conv2d(x, kernel, rate=1,
def separable_conv2d(x, depthwise_kernel, pointwise_kernel, strides=(1, 1), def separable_conv2d(x, depthwise_kernel, pointwise_kernel, strides=(1, 1),
border_mode='valid', dim_ordering='default'): border_mode='valid', dim_ordering='default'):
"""2-D convolution with separable filters. """2-D convolution with separable filters.
# Raises
ValueError: if `dim_ordering` is neither `tf` or `th`.
""" """
if dim_ordering == 'default': if dim_ordering == 'default':
dim_ordering = image_dim_ordering() dim_ordering = image_dim_ordering()
@ -2744,6 +2781,9 @@ def conv3d(x, kernel, strides=(1, 1, 1),
# Returns # Returns
A tensor, result of 3D convolution. A tensor, result of 3D convolution.
# Raises
ValueError: if `dim_ordering` is neither `tf` or `th`.
""" """
if dim_ordering == 'default': if dim_ordering == 'default':
dim_ordering = image_dim_ordering() dim_ordering = image_dim_ordering()
@ -2773,6 +2813,10 @@ def pool2d(x, pool_size, strides=(1, 1),
# Returns # Returns
A tensor, result of 2D pooling. 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': if dim_ordering == 'default':
dim_ordering = image_dim_ordering() dim_ordering = image_dim_ordering()
@ -2808,6 +2852,10 @@ def pool3d(x, pool_size, strides=(1, 1, 1), border_mode='valid',
# Returns # Returns
A tensor, result of 3D pooling. 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': if dim_ordering == 'default':
dim_ordering = image_dim_ordering() dim_ordering = image_dim_ordering()