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

Function average

python/singa/tensor.py:1128–1142  ·  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

1126
1127
1128def average(t, axis=None):
1129 '''
1130 Args:
1131 t (Tensor): input Tensor
1132 axis (int, optional): if None, average all elements; otherwise average
1133 along the given dimension. 0 for averaging each column; 1 for
1134 averaging each row.
1135
1136 Returns:
1137 a float value if axis is None; otherwise, a new Tensor for the result.
1138 '''
1139 if t.ndim() > 1:
1140 return _call_singa_func(singa.Average, t.data, axis)
1141 else:
1142 return singa.SumAsFloat(t.data) / t.size()
1143
1144
1145def 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