MCPcopy Create free account
hub / github.com/apache/singa / average

Function average

examples/model_selection/Trails/singa_pkg_code/tensor.py:1093–1107  ·  view source on GitHub ↗

Args: t (Tensor): input Tensor axis (int, optional): if None, average all elements; otherwise average along the given dimension. 0 for averaging each column; 1 for averaging each row. Returns: a float value if axis is None; otherwise, a new T

(t, axis=None)

Source from the content-addressed store, hash-verified

1091
1092
1093def average(t, axis=None):
1094 '''
1095 Args:
1096 t (Tensor): input Tensor
1097 axis (int, optional): if None, average all elements; otherwise average
1098 along the given dimension. 0 for averaging each column; 1 for
1099 averaging each row.
1100
1101 Returns:
1102 a float value if axis is None; otherwise, a new Tensor for the result.
1103 '''
1104 if t.ndim() > 1:
1105 return _call_singa_func(singa.Average, t.data, axis)
1106 else:
1107 return singa.SumAsFloat(t.data) / t.size()
1108
1109
1110def softmax(t, out=None):

Callers

nothing calls this directly

Calls 3

_call_singa_funcFunction · 0.70
ndimMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected