Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove redundant argument to range(). #8108

Merged
merged 3 commits into from
Oct 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/conv_filter_visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def normalize(x):


kept_filters = []
for filter_index in range(0, 200):
for filter_index in range(200):
# we only scan through the first 200 filters,
# but there are actually 512 of them
print('Processing filter %d' % filter_index)
Expand Down
4 changes: 2 additions & 2 deletions examples/image_ocr.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ def get_batch(self, index, size, train):
input_length = np.zeros([size, 1])
label_length = np.zeros([size, 1])
source_str = []
for i in range(0, size):
for i in range(size):
# Mix in some blank inputs. This seems to be important for
# achieving translational invariance
if train and i > size - 4:
Expand Down Expand Up @@ -372,7 +372,7 @@ def show_edit_distance(self, num):
word_batch = next(self.text_img_gen)[0]
num_proc = min(word_batch['the_input'].shape[0], num_left)
decoded_res = decode_batch(self.test_func, word_batch['the_input'][0:num_proc])
for j in range(0, num_proc):
for j in range(num_proc):
edit_dist = editdistance.eval(decoded_res[j], word_batch['source_str'][j])
mean_ed += float(edit_dist)
mean_norm_ed += float(edit_dist) / len(word_batch['source_str'][j])
Expand Down
2 changes: 1 addition & 1 deletion keras/backend/cntk_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ def dot(x, y):
y_shape = int_shape(y)
if len(y_shape) > 2:
permutation = [len(y_shape) - 2]
permutation += list(range(0, len(y_shape) - 2))
permutation += list(range(len(y_shape) - 2))
permutation += [len(y_shape) - 1]
y = C.transpose(y, perm=permutation)
return C.times(x, y, len(y_shape) - 1)
Expand Down
4 changes: 2 additions & 2 deletions keras/backend/tensorflow_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -3732,11 +3732,11 @@ def range_less_than(_, current_input):
initializer=init, parallel_iterations=1)
dense_mask = dense_mask[:, 0, :]

label_array = tf.reshape(tf.tile(tf.range(0, label_shape[1]), num_batches_tns),
label_array = tf.reshape(tf.tile(tf.range(label_shape[1]), num_batches_tns),
label_shape)
label_ind = tf.boolean_mask(label_array, dense_mask)

batch_array = tf.transpose(tf.reshape(tf.tile(tf.range(0, label_shape[0]),
batch_array = tf.transpose(tf.reshape(tf.tile(tf.range(label_shape[0]),
max_num_labels_tns), reverse(label_shape, 0)))
batch_ind = tf.boolean_mask(batch_array, dense_mask)
indices = tf.transpose(tf.reshape(concatenate([batch_ind, label_ind], axis=0), [2, -1]))
Expand Down
2 changes: 1 addition & 1 deletion keras/engine/training.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ def _make_batches(size, batch_size):
"""
num_batches = int(np.ceil(size / float(batch_size)))
return [(i * batch_size, min(size, (i + 1) * batch_size))
for i in range(0, num_batches)]
for i in range(num_batches)]


def _slice_arrays(arrays, start=None, stop=None):
Expand Down
2 changes: 1 addition & 1 deletion tests/keras/backend/backend_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ def test_in_top_k(self):
targets = np.random.randint(num_classes, size=batch_size, dtype='int32')

# (k == 0 or k > num_classes) does not raise an error but just return an unmeaningful tensor.
for k in range(0, num_classes + 1):
for k in range(num_classes + 1):
z_list = [b.eval(b.in_top_k(b.variable(predictions, dtype='float32'),
b.variable(targets, dtype='int32'), k))
for b in [KTH, KTF]]
Expand Down