2024年最全山东大学人工智能导论实验一 numpy的基本操作(3),一个三非渣本的Golang校招秋招之路

img
img
img

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上Go语言开发知识点,真正体系化!

由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新

如果你需要这些资料,可以戳这里获取

目录

【实验目标】

【实验内容】

【代码要求】

【文档要求】

1. 代码运行结果截图(main函数里的内容不要修改)​编辑

2. sigmoid函数的公式及图像

3. sigmoid函数梯度求解公式及图像

4. softmax函数公式

5. cross entropy loss function公式

6.  它们在神经网络中有什么用处?


【实验目标】

1.熟悉numpy的一些基本函数
2.理解sigmoid, softmax, cross entropy loss等函数

【实验内容】

使用numpy实现深度学习任务中的一些基本操作,包括以下函数:

  1. sigmoid function
def sigmoid(x):  
    """ 
    Compute the sigmoid of x 
 
    Arguments: 
    x -- A scalar or numpy array of any size 
    Return: 
    s -- sigmoid(x) 
    """  
    # write your code here  
    fx = []  
    for num in x:  
        fx.append(1 / (1 + math.exp(-num)))  
    return fx 

  1. sigmoid gradient function
def sigmoid_derivative(x):  
    """ 
    Compute the gradient (also called the slope or derivative) of the sigmoid function with respect to its input x. 
    You can store the output of the sigmoid function into variables and then use it to calculate the gradient. 
 
    Arguments: 
    x -- A scalar or numpy array 
    Return: 
    ds -- Your computed gradient. 
    """  
    # write your code here  
    y = []  
    fx = []  
    for num in x:  
        y.append(1 / (1 + math.exp(-num)))  
    for n in y:  
        fx.append(n * (1 - n))  
    return fx  

  1. softmax function
def softmax(x):  
    """Calculates the softmax for the input x. 
    Argument: 
    x -- A numpy matrix of shape (n,) 
 
    Returns: 
    s -- A numpy matrix equal to the softmax of x, of shape (n,) 
    """  
    # write your code here  
    x_exp = np.exp(x)  
    x_sum = np.sum(x_exp, axis=0, keepdims=True)  
    fx = x_exp / x_sum  
    return fx  

  1. cross entropy loss function
def cross_entropy_loss(target, prediction):  
    """ 
    Compute the cross entropy loss between target and prediction 
    Arguments: 
    target -- the real label, a scalar or numpy array size = (n,) 
    prediction -- the output of model,  a scalar or numpy array, size=(n, c) 
 
    Return: 
    mean loss -- cross_entropy_loss(target, prediction) 
    """  
    # write your code here  
    batch_loss = 0.  
    for i in range(prediction.shape[0]):  
        numerator = np.exp(prediction[i, target[i]])  # 分子  
        denominator = np.sum(np.exp(prediction[i, :]))  # 分母  
  
        # Calculating losses  
        loss = -np.log(numerator / denominator)  
        batch_loss += loss  
    return batch_loss

【代码要求】

1.按代码模板实现函数功能

【文档要求】

1. 代码运行结果截图(main函数里的内容不要修改)

img
img
img

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上Go语言开发知识点,真正体系化!

由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新

如果你需要这些资料,可以戳这里获取

经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上Go语言开发知识点,真正体系化!**

由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新

如果你需要这些资料,可以戳这里获取

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值