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

Function eye

python/singa/initializer.py:41–53  ·  view source on GitHub ↗

Initialize the tensor with ones on the diagonal and zeros elsewhere. Note: it is implemented by calling numpy. Do not call it within forward propagation when computation graph is enabled. # Arguments t(Tensor): the matrix to be filled in.

(t)

Source from the content-addressed store, hash-verified

39
40
41def eye(t):
42 """Initialize the tensor with ones on the diagonal and zeros elsewhere.
43
44 Note: it is implemented by calling numpy.
45 Do not call it within forward propagation when computation graph is enabled.
46
47 # Arguments
48 t(Tensor): the matrix to be filled in.
49 """
50 if len(t.shape) == 2:
51 raise ValueError("Only tensors with 2 dimensions are supported")
52 a = np.eye(t.shape[0], t.shape[1], dtype=np.float32)
53 t.copy_from(a)
54
55
56def orthogonal(t, gain=1.0):

Callers

nothing calls this directly

Calls 1

copy_fromMethod · 0.45

Tested by

no test coverage detected