Spaces:
Running on Zero
Running on Zero
File size: 297 Bytes
2680bd5 | 1 2 3 4 5 6 7 8 9 10 11 | def mean_flat(tensor):
"""
Take the mean over all non-batch dimensions.
"""
return tensor.mean(dim=list(range(1, len(tensor.shape))))
def sum_flat(tensor):
"""
Take the sum over all non-batch dimensions.
"""
return tensor.sum(dim=list(range(1, len(tensor.shape)))) |