AI

Pytorch multinominal采样函数

torch.multinominal方法可以根据给定权重对数组进行多次采样,返回采样后的元素下标 参数说明 input :权重,也就是取每个值的概率,可以是1维或2维。可以不进行归一化。 num_samples : 采样的次数。如果input是二维的,则表示每行的采样次数 replacement :默认值值是False,即不放回采样。如果replacement =False,则num_samples必须小于input中非零元素的数目 按权重采样 从四个元素中随机选择两个,每个元素被选择到的概率分别为:[0.2, 0.2, 0.3, 0.3]: >>> weights = torch.Tensor([0.9, 0.25, 0.1, 0.15]) # 采样权重 >>> torch.multinomial(weights, 2) tensor([0, 1]) >>> torch.multinomial(weights, 2) tensor([1, 3]) >>> torch.multinomial(weights, 2) tensor([0, 3]) >>> torch.multinomial(weights, 2) tensor([3, 1]) >>> torch.multinomial(weights, 2) tensor([1, 0]) >>> torch.multinomial(weights, 2) tensor([1, 0]) >>> torch.multinomial(weights, 2) tensor([0, 1]) >>> torch.multinomial(weights, 2) tensor([0, 2]) >>> torch.multinomial(weights, 2) tensor([3, 0]) >>> torch.

面部生物识别学习笔记

Once the face is detected, the AI then provides the information on its size, pose, and location The state-of-the-art face detection software uses pattern detection technology. No personal data is collected, and no images are stored. 人脸检测基本方法 #Import Libraries #Import Classifier for Face and Eye Detection #Convert Image to Grayscale #Give coordinates to detect face and eyes location from ROI #Webcam setup for Face Detection #When everything is done, release the capture

图像处理中的卷积核kernel

图像处理中的卷积核kernel 简介 卷积核(kernel),也叫卷积矩阵(convolution matrix)或者掩膜(mask),本质上是一个非常小的矩阵,最常用的是 3×3 矩阵。主要是利用核与图像之间进行卷积运算来实现图像处理,能做出模糊、锐化、凹凸、边缘检测等效果。 卷积运算 第一个矩阵是卷积核(其中的每个元素都是权重),第二个矩阵是被处理的矩阵,这里的并不是真正矩阵运算中,而是将卷积核中的行和列都反转再*,将计算得到的加权结果赋值给[2, 2]位置处. 将一个比较大的原始矩阵的每一个位置处都根据核进行上述的运算,就得到整个原始矩阵的加权平均结果,也就是原始矩阵卷积运算后的结果 [1]https://blog.csdn.net/i_silence/article/details/116483732

machine learning basic

机器学习是统计模型 对文本标签配对进行统计模型训练,使模型能够使用代表消息意图的预定义标签对未知输入文本进行分类 a statistical model is trained on text-label pairings, enabling the model to classify unknown input text with a pre-defined label representing the intention of the message Early neural networks Although the core ideas of neural networks were investigated in toy forms as early as the 1950s, the approach took decades to really get started. For a long time, the missing piece was a lack of an efficient way to train large neural networks.