Esse commit está contido em:
Taehoon Lee
2017-06-22 02:58:38 +09:00
commit de François Chollet
commit f430de10fb
8 arquivos alterados com 45 adições e 30 exclusões
+2 -2
Ver Arquivo
@@ -136,8 +136,8 @@ def shuffle_mats_or_lists(matrix_list, stop_ind=None):
elif isinstance(mat, list):
ret.append([mat[i] for i in a])
else:
raise TypeError('shuffle_mats_or_lists only supports '
'numpy.array and list objects')
raise TypeError('`shuffle_mats_or_lists` only supports '
'numpy.array and list objects.')
return ret
+1 -1
Ver Arquivo
@@ -77,7 +77,7 @@ def identity_block(input_tensor, kernel_size, filters, stage, block):
def conv_block(input_tensor, kernel_size, filters, stage, block, strides=(2, 2)):
"""conv_block is the block that has a conv layer at shortcut
"""A block that has a conv layer at shortcut.
# Arguments
input_tensor: input tensor
+4 -4
Ver Arquivo
@@ -652,16 +652,16 @@ def _normalize_axis(axis, x):
nones = _get_dynamic_axis_num(x)
if type(axis) is tuple:
if isinstance(axis, tuple):
_axis = list(axis)
elif type(axis) is int:
elif isinstance(axis, int):
_axis = [axis]
elif type(axis) is list:
elif isinstance(axis, list):
_axis = list(axis)
else:
_axis = axis
if type(_axis) is list:
if isinstance(_axis, list):
for i, a in enumerate(_axis):
if a is not None and a < 0:
_axis[i] = (a % ndim)
+22 -7
Ver Arquivo
@@ -446,10 +446,14 @@ def transpose(x):
def gather(reference, indices):
"""reference: a tensor.
indices: an int tensor of indices.
"""Retrieves the elements of indices `indices` in the tensor `reference`.
Return: a tensor of same type as reference.
# Arguments
reference: A tensor.
indices: An integer tensor of indices.
# Returns
A tensor of same type as `reference`.
"""
y = reference[indices]
if hasattr(reference, '_keras_shape') and hasattr(indices, '_keras_shape'):
@@ -930,7 +934,7 @@ def tile(x, n):
output_shape += (None,)
else:
output_shape += (i * j,)
elif type(n) is int:
elif isinstance(n, int):
output_shape = x._keras_shape[:-1]
if x._keras_shape[-1] is None:
output_shape += (None,)
@@ -1138,8 +1142,8 @@ def pattern_broadcast(x, broatcastable):
def get_value(x):
if not hasattr(x, 'get_value'):
raise TypeError('get_value() can only be called on a variable. '
'If you have an expression instead, use eval().')
raise TypeError('`get_value` can only be called on a variable. '
'If you have an expression instead, use `eval()`.')
return x.get_value()
@@ -1386,7 +1390,18 @@ def rnn(step_function, inputs, initial_states,
def switch(condition, then_expression, else_expression):
"""condition: scalar tensor.
"""Switches between two operations depending on a scalar value.
Note that both `then_expression` and `else_expression`
should be symbolic tensors of the *same shape*.
# Arguments
condition: scalar tensor (`int` or `bool`).
then_expression: either a tensor, or a callable that returns a tensor.
else_expression: either a tensor, or a callable that returns a tensor.
# Returns
The selected tensor.
"""
if callable(then_expression):
then_expression = then_expression()
+1 -1
Ver Arquivo
@@ -19,7 +19,7 @@ def load_data(label_mode='fine'):
ValueError: in case of invalid `label_mode`.
"""
if label_mode not in ['fine', 'coarse']:
raise ValueError('label_mode must be one of "fine" "coarse".')
raise ValueError('`label_mode` must be one of `"fine"`, `"coarse"`.')
dirname = 'cifar-100-python'
origin = 'http://www.cs.toronto.edu/~kriz/cifar-100-python.tar.gz'
+6 -6
Ver Arquivo
@@ -563,7 +563,7 @@ def _standardize_weights(y, sample_weight=None, class_weight=None,
return sample_weight
elif isinstance(class_weight, dict):
if len(y.shape) > 2:
raise ValueError('class_weight not supported for '
raise ValueError('`class_weight` not supported for '
'3+ dimensional targets.')
if y.shape[1] > 1:
y_classes = y.argmax(axis=1)
@@ -1756,7 +1756,7 @@ class Model(Container):
elif len(validation_data) == 3:
val_x, val_y, val_sample_weight = validation_data
else:
raise ValueError('validation_data should be a tuple '
raise ValueError('`validation_data` should be a tuple '
'`(val_x, val_y, val_sample_weight)` '
'or `(val_x, val_y)`. Found: ' +
str(validation_data))
@@ -1795,7 +1795,7 @@ class Model(Container):
generator_output = next(output_generator)
if not hasattr(generator_output, '__len__'):
raise ValueError('output of generator should be '
raise ValueError('Output of generator should be '
'a tuple `(x, y, sample_weight)` '
'or `(x, y)`. Found: ' +
str(generator_output))
@@ -1805,7 +1805,7 @@ class Model(Container):
elif len(generator_output) == 3:
x, y, sample_weight = generator_output
else:
raise ValueError('output of generator should be '
raise ValueError('Output of generator should be '
'a tuple `(x, y, sample_weight)` '
'or `(x, y)`. Found: ' +
str(generator_output))
@@ -1939,7 +1939,7 @@ class Model(Container):
while steps_done < steps:
generator_output = next(output_generator)
if not hasattr(generator_output, '__len__'):
raise ValueError('output of generator should be a tuple '
raise ValueError('Output of generator should be a tuple '
'(x, y, sample_weight) '
'or (x, y). Found: ' +
str(generator_output))
@@ -1949,7 +1949,7 @@ class Model(Container):
elif len(generator_output) == 3:
x, y, sample_weight = generator_output
else:
raise ValueError('output of generator should be a tuple '
raise ValueError('Output of generator should be a tuple '
'(x, y, sample_weight) '
'or (x, y). Found: ' +
str(generator_output))
+5 -5
Ver Arquivo
@@ -193,8 +193,8 @@ class SpatialDropout2D(Dropout):
if data_format is None:
data_format = K.image_data_format()
if data_format not in {'channels_last', 'channels_first'}:
raise ValueError('data_format must be in '
'{"channels_last", "channels_first"}')
raise ValueError('`data_format` must be in '
'{`"channels_last"`, `"channels_first"`}')
self.data_format = data_format
self.input_spec = InputSpec(ndim=4)
@@ -246,8 +246,8 @@ class SpatialDropout3D(Dropout):
if data_format is None:
data_format = K.image_data_format()
if data_format not in {'channels_last', 'channels_first'}:
raise ValueError('data_format must be in '
'{"channels_last", "channels_first"}')
raise ValueError('`data_format` must be in '
'{`"channels_last"`, `"channels_first"`}')
self.data_format = data_format
self.input_spec = InputSpec(ndim=5)
@@ -637,7 +637,7 @@ class Lambda(Layer):
else:
shape = self._output_shape(input_shape)
if not isinstance(shape, (list, tuple)):
raise ValueError('output_shape function must return a tuple')
raise ValueError('`output_shape` function must return a tuple.')
return tuple(shape)
def call(self, inputs, mask=None):
+4 -4
Ver Arquivo
@@ -139,7 +139,7 @@ def random_zoom(x, zoom_range, row_axis=1, col_axis=2, channel_axis=0,
ValueError: if `zoom_range` isn't a tuple.
"""
if len(zoom_range) != 2:
raise ValueError('zoom_range should be a tuple or list of two floats. '
raise ValueError('`zoom_range` should be a tuple or list of two floats. '
'Received arg: ', zoom_range)
if zoom_range[0] == 1 and zoom_range[1] == 1:
@@ -421,8 +421,8 @@ class ImageDataGenerator(object):
self.preprocessing_function = preprocessing_function
if data_format not in {'channels_last', 'channels_first'}:
raise ValueError('data_format should be "channels_last" (channel after row and '
'column) or "channels_first" (channel before row and column). '
raise ValueError('`data_format` should be `"channels_last"` (channel after row and '
'column) or `"channels_first"` (channel before row and column). '
'Received arg: ', data_format)
self.data_format = data_format
if data_format == 'channels_first':
@@ -443,7 +443,7 @@ class ImageDataGenerator(object):
elif len(zoom_range) == 2:
self.zoom_range = [zoom_range[0], zoom_range[1]]
else:
raise ValueError('zoom_range should be a float or '
raise ValueError('`zoom_range` should be a float or '
'a tuple or list of two floats. '
'Received arg: ', zoom_range)