目录
python反解sigmoid
import numpy as np
def invert_sigmoid(y):
if y <= 0 or y >= 1:
raise ValueError("y must be between 0 and 1, exclusive.")
x = np.log(y / (1 - y))
return x
# 示例
y = 0.8
x = invert_sigmoid(y)
print(f"The value of x that results in a sigmoid output of {y} is {x}")
torch sigmoid练习
import torch
import datetime
tensor_1 = torch.FloatTensor([-5000,-0.1,0.1,5,6,8,10.0,1000])
x = torch.sigmoid(tensor_1) # Center x
print(x)
结果:
tensor([ 0.0000, 0.4750, 0.5250, 0.993