其他分享
首页 > 其他分享> > Numpy基础

Numpy基础

作者:互联网

Numpy基础

s =1/(1+math.exp(-x)) #不能用作向量
import numpy as np
# numpy可以用作向量
# example of np.exp
x = np.array([1, 2, 3])
print(np.exp(x)) # result is (exp(1), exp(2), exp(3))

image-20211229111800109

实现一个sigmod

import numpy as np # this means you can access numpy functions by writing np.function() instead of numpy.function()

def sigmoid(x):
    """
    Compute the sigmoid of x

    Arguments:
    x -- A scalar or numpy array of any size

    Return:
    s -- sigmoid(x)
    """
    
    ### START CODE HERE ### (≈ 1 line of code)
    s = 1 / (1 + np.exp(-x))
    ### END CODE HERE ###
    
    return s
x = np.array([1, 2, 3])
sigmoid(x)
out[9]:array([0.73105858, 0.88079708, 0.95257413])

Sigmoid gradient

标签:sigmoid,numpy,基础,shape,np,array,Numpy,###
来源: https://www.cnblogs.com/suehoo/p/15744511.html