4b4946f40ef0f8c533f5473ec3756e639e57e5c5,python/baseline/dy/dynety.py,,show_examples_dynet,#Any#Any#Any#Any#Any#Any#Any#Any#Any#Any#,487
Before Change
src_len = batch_dict["src_len"]
if max_examples > 0:
max_examples = min(max_examples, src_array.shape[0])
src_array = src_array[0:max_examples]
tgt_array = tgt_array[0:max_examples]
src_len = src_len[0:max_examples]
for src_len_i, src_i, tgt_i in zip(src_len, src_array, tgt_array):
print("========================================================================")
src_len_i = np.array(src_len_i, ndmin=1)
sent = lookup_sentence(rlut1, src_i, reverse=reverse)
print("[OP] %s" % sent)
sent = lookup_sentence(rlut2, tgt_i)
print("[Actual] %s" % sent)
src_dict = {"src": src_i.reshape(1, -1), "src_len": src_len_i}
dst_i = model.run(src_dict)[0]
sent = lookup_sentence(rlut2, dst_i)
print("Guess: %s" % sent)
print("------------------------------------------------------------------------")
After Change
batch_dict = es[si]
lengths_key = model.src_lengths_key
src_field = lengths_key.split("_")[0]
src_array = batch_dict[src_field]
if max_examples > 0:
max_examples = min(max_examples, src_array.shape[0])
for i in range(max_examples):
example = {}
// Batch first, so this gets a single example at once
for k, value in batch_dict.items():
v = value[i]
example[k] = v.reshape((1,) + v.shape)
print("========================================================================")
sent = lookup_sentence(rlut1, example[src_field].squeeze(), reverse=reverse)
print("[OP] %s" % sent)
sent = lookup_sentence(rlut2, example["tgt"].squeeze())
print("[Actual] %s" % sent)
dst_i = model.run(example)[0]
sent = lookup_sentence(rlut2, dst_i)
print("Guess: %s" % sent)
print("------------------------------------------------------------------------")
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 6
Instances
Project Name: dpressel/mead-baseline
Commit Name: 4b4946f40ef0f8c533f5473ec3756e639e57e5c5
Time: 2018-09-28
Author: dpressel@gmail.com
File Name: python/baseline/dy/dynety.py
Class Name:
Method Name: show_examples_dynet
Project Name: nilearn/nilearn
Commit Name: 9df22084c5753cd5b3480afddee054dcdd774438
Time: 2017-05-29
Author: dkamalakarreddy@gmail.com
File Name: nilearn/datasets/atlas.py
Class Name:
Method Name: fetch_atlas_harvard_oxford
Project Name: tensorflow/datasets
Commit Name: 16a69e5630ff233b4d289c3f0dba58ca556b494f
Time: 2019-03-12
Author: sjana646@gmail.com
File Name: tensorflow_datasets/image/ham10000.py
Class Name: Ham10000
Method Name: _generate_examples