def test_bias(self): img = sail.random.uniform(0, 1, (64, 4, 60, 60)) lay = sail.modules.Conv2D(4, 32, 3, 1, padding_mode="same", use_bias=True) y = lay(img) self.assert_eq(y.shape, (64, 32, 60, 60)) z = sail.sum(y) z.backward()
def forward(a, b, d, f): c = (a / b) + (d * f) h = sail.exp(c) g = h - sail.max(h, 1, True) + d - c i = sail.sum(h) return i
def test(self): img = sail.random.uniform(0, 1, (64, 4, 60, 60)) lay = sail.modules.MaxPool2D(2)#(2,2)) y = lay(img) self.assert_eq(y.shape, (64, 4, 30, 30)) z = sail.sum(y) z.backward()
def test_sum(self, rq): times = [] for c in choices: arr1 = np.random.uniform(0, 1, (c["shape"])) x1 = sail.Tensor(arr1, requires_grad=rq) x3 = sail.sum(x1, c['axis'], keepdims=c['keepdims']) arr3 = np.sum(arr1, c["axis"], keepdims=c['keepdims']) self.assert_eq(x3.shape, c["result_shape"]) self.assert_eq_np_sail(arr3, x3, 1e-7) self.assert_eq(x3.requires_grad, rq) return
sail.log(tensor) -> Tensor Returns natural log of `tensor` .. math:: \text{out} = ln(\text{tensor}) Args: tensor (Tensor): Input data Examples: >>> a = sail.random.uniform(1, 2, (20, 3)) >>> b = sail.log(a) """ add_docstring(sail.log, descr) descr = r""" sail.sum(tensor, axis=None, keepdims=False) -> Tensor Returns the sum of `tensor` over specified axis. .. note:: If ``axis < 0``, then the axis that will be computed over is ``tensor.ndim + axis``. Args: tensor (Tensor): Input data axis (int or tuple of ints, optional): If provided, then `axis` represents the axis to be summed over. If `axis` is a tuple, then the axes provided will be summed over keepdims (boolean, optional): If True, then the axes that are reduced will be replaced with 1, otherwise, those axes will be removed Examples: >>> x = sail.random.uniform(0, 1, (12, 32, 4, 5)) >>> y = sail.sum(x, 1, True) >>> y.shape
def forward(a): c = sail.modules.ReLU()(a) d = sail.sum(c) return d
def forward(a): c = sail.modules.Softmax()(a) d = sail.sum(c) return d
def forward(a): c = sail.clip(a, 4, 6) d = sail.sum(c) return d
def forward(a, b, c): d = sail.addmm(a, b, c) e = sail.sum(d) return e
def forward(a): c = -a d = sail.sum(c) return d
def forward(a): c = sail.exp(a) d = sail.sum(c) return d
def forward(a, b): c = sail.power(a, b) d = sail.sum(c) return d
def forward(a, b): c = a / b d = sail.sum(c) return d
def forward(a, b): c = sail.add(a, b) d = sail.sum(c) return d
def forward(a, b): c = sail.matmul(a, b) d = sail.sum(c) return d
def forward(a): y = sail.sum(a) return y
def forward(a): c = sail.log(a) d = sail.sum(c) return d