db9d883aecb6cdfba6c6bbc76b83d85397fef28d,maml_rl/utils/torch_utils.py,,weighted_mean,#Any#Any#Any#,4
Before Change
sum_weights = torch.sum(weights)
return torch.sum(tensor * weights) / sum_weights
if isinstance(dim, int):
dim = (dim,)
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):
After Change
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)
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 3
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: metalbubble/moments_models
Commit Name: 70e4855f5608c4481dfffd5f762e310d631d06c3
Time: 2020-10-09
Author: mmonfort@mit.edu
File Name: test_model_CAM.py
Class Name:
Method Name: returnCAM