- 博客(14)
- 收藏
- 关注
原创 softmax sigmoid计算交叉熵损失
1.在上述例子中使用nn.CrossEntropyLoss(),计算的是3分类损失。而使用nn.BCEWithLogitsLoss(),计算的是3个二分类损失。2.使用sigmoid激活,可以用于多标签图像分类。3.二分类损失计算公式中的pi为正样本的概率。具体来说,在使用softmax时为对类别1的预测概率,在使用sigmoid时,就为sigmoid的输出。CrossEntropy交叉熵损失函数及softmax函数的理解一文读懂交叉熵损失函数完整实验代码。
2023-08-07 16:18:28
359
1
原创 语义分割 评价指标(global_acc, mean_acc, mean_iou)等numpy实现
语义分割常见评价指标global_acc, mean_acc, mean_iou计算,个人学习记录,仅供参考。一、理论计算假设真实标签为:预测标签为:则手动列出混淆矩阵可得:1.1 全局准确率预测正确的像素数量 / 总的像素数量global_acc = (1+1+1+1+0) / 9 = 4 / 9 = 0.4444,即混淆矩阵对角线元素之和除以混淆矩阵所有元素和。1.2 平均准确率分别算出每一类的准确率,分子为对角线元素,分母为真实标签i数量,这里具体为第i行的元素和。cls_0
2021-12-19 17:42:38
8164
9
原创 lambda函数,map()
一级标题二级标题三级标题四级标题五级标题六级标题一.lambda函数:1.单个参数lambda:a = lambda x: x * 3 + 6print('a(2):', a(2))输出:a(2): 122.多个参数lambda:b = lambda x, y : x + yprint('b(8, 9):', b(8, 9))c = lambda x, y, z : x * y * zprint('c(6, 7, 8):', c(6, 7, 8))输出:b(8,
2021-09-30 11:00:53
764
原创 数据归一化,标准化
一. min-max标准化(Min-Max Normalization)也称离差标准化,将数据调整到[0,1],公式:x* = (x - min(x)) / (max(x) - min(x))代码实现:import numpy as npA = np.array([2, 7, 36, 89, 169, 235, 1021])print('调整前A:\n', A)gui = (A - np.min(A)) / (np.max(A) - np.min(A))print('调整后A:\n', g
2021-09-16 09:53:48
3926
原创 python保存读取mat文件
1.使用python将数组存为mat文件import numpy as npimport scipy.io as sciodata = np.random.randn(4,3)print('data.shape:', data.shape)print('data \n', data)#//保存mat文件scio.savemat('test.mat', {'array': data})输出结果:data.shape: (4, 3)data [[-0.40026532 -0.895
2021-09-06 21:11:30
1751
1
原创 导入本地已下载的MNIST数据集
导入本地已下载的MNIST数据集,四个文件:t10k-images-idx3-ubyte.gzt10k-labels-idx1-ubyte.gztrain-images-idx3-ubyte.gztrain-labels-idx1-ubyte.gzimport matplotlib.pyplot as pltimport gzipimport numpy as npimport osdef load_data_gz(data_folder): files = ['train-la
2021-09-05 20:51:35
3004
原创 tensorflow2.0 datasets.shuffle(buffer_size).batch(batch_size)
一些个人理解,记录参考// An highlighted blockimport tensorflow as tf(train_images, train_labels), (_, _) = tf.keras.datasets.mnist.load_data()print('读入初始训练图像, train_images.shape:', train_images.shape)train_images = train_images[0:5000, :, :]print('取前5000个训练图像
2021-09-03 18:00:07
1215
原创 Win10 Anaconda 安装 pytorch cpu
Win10 Anaconda 安装pytorch cpu1. 打开anaconda prompt添加镜像源2. anaconda prompt中创建虚拟环境3. 激活虚拟环境4. 安装5. 检查是否安装成功1. 打开anaconda prompt添加镜像源conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/conda config --add channels https://mir
2021-08-20 21:06:56
209
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人