分类任务与激活函数

分类任务可分为:二分类,多分类,多标签分类

1.分类任务

二分类
在这里插入图片描述
多分类
在这里插入图片描述
多标签分类
在这里插入图片描述

2.建模上的区别

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

3.代码实现
# 激活函数练习

# sigmoid
import numpy as np


# 输入的数字越小 越靠近0,数字越大越靠近1
def sigmoid(x):
    return 1.0 / (1 + np.exp(-x))


print(sigmoid(0.1))

# 画图
import matplotlib.pyplot as plt

sigmoid_input = np.arange(-10, 10)
sigmoid_output = sigmoid(sigmoid_input)
print('sigmoid function input:{}'.format(sigmoid_input.shape))
print('sigmoid function output:{}'.format(sigmoid_output.shape))
plt.plot(sigmoid_input, sigmoid_output)
plt.xlabel('sigmoid input')
plt.xlabel('sigmoid output')
plt.show()

# softmax
import math

softmax_input = [1.0, 2.0, 3.0, 4.0, 5.0, 7.0, 8.0]
z_exp = [math.exp(i) for i in softmax_input]
print(z_exp)
sum_z_exp = sum(z_exp)
softmax_output = [round(ex/sum_z_exp,2) for ex in z_exp]
print(softmax_input)
print(softmax_output)

plt.plot(softmax_input, softmax_output)
plt.xlabel('softmax input')
plt.xlabel('softmax output')
plt.show()
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Cocktail_py

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值