*Memos:
- My post explains log() and log1p().
- My post explains log2() and log10().
- My post explains exp() and exp2().
expm1() can get the 0D or more D tensor of the zero or more elements by e
x - 1 from the 0D or more D tensor of zero or more elements as shown below:
*Memos:
-
expm1()
can be used with torch or a tensor. - The 1st argument(
input
) withtorch
or using a tensor(Required-Type:tensor
ofint
,float
,complex
orbool
). - There is
out
argument withtorch
(Optional-Default:None
-Type:tensor
): *Memos:-
out=
must be used. -
My post explains
out
argument.
-
- *A
float
tensor is returned unless an input tensor iscomplex
tensor. -
torch.expm1()
is the alias of torch.special.expm1(). - The formula is y = ex - 1.
- The graph in Desmos:
import torch
my_tensor = torch.tensor([-2., -1., 0., 1., 2., 3.])
torch.expm1(input=my_tensor)
my_tensor.expm1()
# tensor([-0.8647, -0.6321, 0.0000, 1.7183, 6.3891, 19.0855])
my_tensor = torch.tensor([[-2., -1., 0.],
[1., 2., 3.]])
torch.expm1(input=my_tensor)
# tensor([[-0.8647, -0.6321, 0.0000],
# [1.7183, 6.3891, 19.0855]])
my_tensor = torch.tensor([[-2, -1, 0],
[1, 2, 3]])
torch.expm1(input=my_tensor)
# tensor([[-0.8647, -0.6321, 0.0000],
# [1.7183, 6.3891, 19.0855]])
my_tensor = torch.tensor([[-2.+0.j, -1.+0.j, 0.+0.j],
[1.+0.j, 2.+0.j, 3.+0.j]])
torch.expm1(input=my_tensor)
# tensor([[-0.8647+0.j, -0.6321+0.j, 0.0000+0.j],
# [1.7183+0.j, 6.3891+0.j, 19.0855+0.j]])
my_tensor = torch.tensor([[True, False, True],
[False, True, False]])
torch.expm1(input=my_tensor)
# tensor([[1.7183, 0.0000, 1.7183],
# [0.0000, 1.7183, 0.0000]])
sigmoid() can get the 0D or more D tensor of the zero or more elements by Sigmoid function from the 0D or more D tensor of zero or more elements as shown below:
*Memos:
-
sigmoid()
can be used withtorch
or a tensor. - The 1st argument(
input
) withtorch
or using a tensor(Required-Type:tensor
ofint
,float
,complex
orbool
). - There is
out
argument withtorch
(Optional-Default:None
-Type:tensor
): *Memos:-
out=
must be used. -
My post explains
out
argument.
-
- *A
float
tensor is returned unless an input tensor iscomplex
tensor. -
torch.sigmoid()
is the alias of torch.special.expit(). - You can also use torch.nn.Sigmoid().
- The formula is y = 1 / (1 + e-
x
). - The graph in Desmos:
import torch
my_tensor = torch.tensor([-2., -1., 0., 1., 2., 3.])
torch.sigmoid(input=my_tensor)
my_tensor.sigmoid()
# tensor([0.1192, 0.2689, 0.5000, 0.7311, 0.8808, 0.9526])
my_tensor = torch.tensor([[-2., -1., 0.],
[1., 2., 3.]])
torch.sigmoid(input=my_tensor)
# tensor([[0.1192, 0.2689, 0.5000],
# [0.7311, 0.8808, 0.9526]])
my_tensor = torch.tensor([[-2, -1, 0],
[1, 2, 3]])
torch.sigmoid(input=my_tensor)
# tensor([[0.1192, 0.2689, 0.5000],
# [0.7311, 0.8808, 0.9526]])
my_tensor = torch.tensor([[-2.+0.j, -1.+0.j, 0.+0.j],
[1.+0.j, 2.+0.j, 3.+0.j]])
torch.sigmoid(input=my_tensor)
# tensor([[0.1192+0.j, 0.2689+0.j, 0.5000+0.j],
# [0.7311+0.j, 0.8808+0.j, 0.9526+0.j]])
my_tensor = torch.tensor([[True, False, True],
[False, True, False]])
torch.sigmoid(input=my_tensor)
# tensor([[0.7311, 0.5000, 0.7311],
# [0.5000, 0.7311, 0.5000]])
Top comments (0)