Skip to content

Commit

Permalink
Further formatting fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
fchollet committed Jan 9, 2018
1 parent 9e6ffc3 commit 4778fa0
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 11 deletions.
2 changes: 2 additions & 0 deletions keras/applications/imagenet_utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""Utilities for ImageNet data preprocessing & prediction decoding.
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
Expand Down
6 changes: 3 additions & 3 deletions keras/applications/nasnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ def NASNetLarge(input_shape=None,
layer at the top of the network.
weights: `None` (random initialization) or
`imagenet` (ImageNet weights)
input_tensor:Ooptional Keras tensor (i.e. output of
input_tensor: Optional Keras tensor (i.e. output of
`layers.Input()`)
to use as image input for the model.
pooling: Optional pooling mode for feature extraction
Expand Down Expand Up @@ -533,7 +533,7 @@ def _adjust_block(p, ip, filters, block_id=None):


def _normal_a_cell(ip, p, filters, block_id=None):
'''Adds a Normal cell for NASNet-A (Fig. 4 in the paper)
'''Adds a Normal cell for NASNet-A (Fig. 4 in the paper).
# Arguments
ip: Input tensor `x`
Expand Down Expand Up @@ -594,7 +594,7 @@ def _normal_a_cell(ip, p, filters, block_id=None):


def _reduction_a_cell(ip, p, filters, block_id=None):
'''Adds a Reduction cell for NASNet-A (Fig. 4 in the paper)
'''Adds a Reduction cell for NASNet-A (Fig. 4 in the paper).
# Arguments
ip: Input tensor `x`
Expand Down
4 changes: 2 additions & 2 deletions keras/datasets/reuters.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ def load_data(path='reuters.npz', num_words=None, skip_top=0,
# reserve 'index_from' (=3 by default) characters:
# 0 (padding), 1 (start), 2 (OOV)
if oov_char is not None:
xs = [[w if (skip_top <= w < num_words) else oov_char for w in x] for x in xs]
xs = [[w if skip_top <= w < num_words else oov_char for w in x] for x in xs]
else:
xs = [[w for w in x if (skip_top <= w < num_words)] for x in xs]
xs = [[w for w in x if skip_top <= w < num_words] for x in xs]

idx = int(len(xs) * (1 - test_split))
x_train, y_train = np.array(xs[:idx]), np.array(labels[:idx])
Expand Down
10 changes: 6 additions & 4 deletions keras/engine/training.py
Original file line number Diff line number Diff line change
Expand Up @@ -697,10 +697,10 @@ def compile(self, optimizer, loss, metrics=None, loss_weights=None,
'dictionary: "' + name + '". '
'Only expected the following keys: ' +
str(self.output_names))
_target_tensors = []
tmp_target_tensors = []
for name in self.output_names:
_target_tensors.append(target_tensors.get(name, None))
target_tensors = _target_tensors
tmp_target_tensors.append(target_tensors.get(name, None))
target_tensors = tmp_target_tensors
else:
raise TypeError('Expected `target_tensors` to be '
'a list or dict, but got:', target_tensors)
Expand Down Expand Up @@ -1020,6 +1020,9 @@ def _check_num_samples(self, ins, batch_size=None, steps=None, steps_name='steps
processed based on the size of the first dimension of the
first input numpy array. When steps is not `None` and
`batch_size` is `None`, returns `None`.
# Raises
ValueError: In case of invalid arguments.
"""
if steps is not None:
num_samples = None
Expand Down Expand Up @@ -1696,7 +1699,6 @@ def evaluate(self, x=None, y=None,
before declaring the evaluation round finished.
Ignored with the default value of `None`.
# Returns
Scalar test loss (if the model has a single output and no metrics)
or list of scalars (if the model has multiple outputs
Expand Down
2 changes: 1 addition & 1 deletion keras/preprocessing/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -956,7 +956,7 @@ def _recursive_list(subpath):
return sorted(os.walk(subpath, followlinks=follow_links), key=lambda tpl: tpl[0])

samples = 0
for root, _, files in _recursive_list(directory):
for _, _, files in _recursive_list(directory):
for fname in files:
is_valid = False
for extension in white_list_formats:
Expand Down
3 changes: 2 additions & 1 deletion keras/utils/layer_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ def print_summary(model, line_length=None, positions=None, print_fn=None):
nodes = []
for v in nodes_by_depth:
if (len(v) > 1) or (len(v) == 1 and len(v[0].inbound_layers) > 1):
# if the model has multiple nodes or if the nodes have multiple inbound_layers
# if the model has multiple nodes
# or if the nodes have multiple inbound_layers
# the model is no longer sequential
sequential_like = False
break
Expand Down

0 comments on commit 4778fa0

Please sign in to comment.