dad75ba3efc4fb3e244288f99ed09d1d125c49cf,baseline/pytorch/embeddings.py,,_mean_pool,#Any#Any#,211

Before Change




def _mean_pool(_, embeddings):
    return torch.mean(embeddings, 1, False)


def _max_pool(_, embeddings):
    return torch.max(embeddings, 1, False)[0]

After Change



def _mean_pool(inputs, embeddings):
    mask = (inputs != 0)
    seq_lengths = mask.sum(1).float()
    embeddings = embeddings.masked_fill(mask.unsqueeze(-1) == False, 0.)
    return embeddings.sum(1)/seq_lengths.unsqueeze(-1)


def _max_pool(inputs, embeddings):
    mask = (inputs != 0)
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 4

Instances


Project Name: dpressel/mead-baseline
Commit Name: dad75ba3efc4fb3e244288f99ed09d1d125c49cf
Time: 2020-05-01
Author: wliu@interactions.com
File Name: baseline/pytorch/embeddings.py
Class Name:
Method Name: _mean_pool


Project Name: dpressel/mead-baseline
Commit Name: b2024a7cb982dcd2009e4436823d02e441e4356f
Time: 2021-02-14
Author: dpressel@gmail.com
File Name: layers/eight_mile/pytorch/layers.py
Class Name: SingleHeadReduction
Method Name: forward


Project Name: allenai/allennlp
Commit Name: d27770a7c9e275a3b3f52e90619bbc5f851754ae
Time: 2018-08-23
Author: mattg@allenai.org
File Name: allennlp/nn/util.py
Class Name:
Method Name: replace_masked_values