db9d883aecb6cdfba6c6bbc76b83d85397fef28d,maml_rl/utils/torch_utils.py,,weighted_mean,#Any#Any#Any#,4

Before Change


    numerator = tensor * weights
    denominator = weights
    for dimension in dim:
        numerator = torch.sum(numerator, dimension, keepdim=True)
        denominator = torch.sum(denominator, dimension, keepdim=True)
    return numerator / denominator

def detach_distribution(pi):
    if isinstance(pi, Categorical):
        distribution = Categorical(logits=pi.logits.detach())

After Change


    if weights is None:
        out = torch.mean(tensor)
    if dim is None:
        out = torch.sum(tensor * weights)
        out.div_(torch.sum(weights))
    else:
        mean_dim = torch.sum(tensor * weights, dim=dim)
        mean_dim.div_(torch.sum(weights, dim=dim))
        out = torch.mean(mean_dim)
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 4

Instances


Project Name: tristandeleu/pytorch-maml-rl
Commit Name: db9d883aecb6cdfba6c6bbc76b83d85397fef28d
Time: 2018-10-23
Author: tristan.deleu@gmail.com
File Name: maml_rl/utils/torch_utils.py
Class Name:
Method Name: weighted_mean


Project Name: PIQuIL/QuCumber
Commit Name: 088b7601d2a21eb092150ae5f4070a8ab52306f3
Time: 2018-08-18
Author: emerali@users.noreply.github.com
File Name: qucumber/observables/pauli.py
Class Name: SigmaX
Method Name: apply


Project Name: Kaixhin/Rainbow
Commit Name: 75fbb7ecbebde47fb7640b62126020f25df152cb
Time: 2017-12-27
Author: design@kaixhin.com
File Name: env.py
Class Name: Env
Method Name: _get_state