《Python Machine Learning》笔记(1)

机器学习分为:unsupervised learning, supervised learning 和 Reinforcement learning

 

Supervised Learning (监督学习)

The main goal in supervised learning is to learn to model from labeled trainning data that allows us to make predictions about unseen or future data. Here the term supervised to a set of samples where the desired output signals (labels) are already known.

 

监督学习可分为两类:

A supervised learning task with discrete(离散的) class labels, is also called a classification task.

Another subcategory of supervised learning is regression, where the outcome signals is a continuous value.

 

流程:

                            Training Data (with Labels)

                                               |

                            Machine Learning Algorithm

                                               |

               New Data -> Predivtive Model -> Prediction 

 

Classification

The goal is to predict the categorical class labels of new instances based on past observations. Thoese class labels are discrete, unordered values that can be understood as the group memberships of the instances. Then the machine learning algorithm learns a set of rules in order to distinguish between two (or more than two) possible classes.

 

 

 

由于没有确切来自Comp90049课程的机器学习介绍部分笔记,但参考常见的机器学习入门知识和提供的引用内容,以下是可能涵盖的笔记内容: ### 卷积神经网络基础 #### 卷积层相关 - **从全连接到卷积**:进行图像识别有两个原则,可从全连接层出发应用这两个原则得到卷积。卷积算子用于图像识别,有二维交叉相关、二维卷积层,还存在一维、三维交叉相关的情况。二维交叉相关与卷积有所不同。 - **填充和步幅**:在卷积层里,填充和步幅是重要概念。填充可改变输出的尺寸,步幅影响卷积操作的移动间隔,并且有对应的代码实现 [^1]。 - **多输入多输出通道**:卷积层存在多个输入通道和多个输出通道的情况。多个输入通道时,卷积操作会考虑不同通道的信息;多个输出通道可增加特征提取的多样性。1*1卷积层是卷积核的高和宽都等于1,它不会识别空间信息,只是融合通道,相当于将输入拉成向量后与权重为co*ci的全连接层进行操作 [^1][^3]。 ```python # 简单示例代码,使用PyTorch创建一个卷积层 import torch import torch.nn as nn # 创建一个卷积层,输入通道为3,输出通道为6,卷积核大小为3 conv_layer = nn.Conv2d(in_channels=3, out_channels=6, kernel_size=3) ``` #### 池化层 池化层有二维最大池化层和平均池化层。最大池化层会选取局部区域的最大值,平均池化层则计算局部区域的平均值,也有对应的代码实现 [^1]。 ```python # 简单示例代码,使用PyTorch创建一个最大池化层 import torch import torch.nn as nn # 创建一个最大池化层,池化核大小为2,步幅为2 max_pool = nn.MaxPool2d(kernel_size=2, stride=2) ``` #### 经典卷积神经网络LeNet LeNet是经典的卷积神经网络,有其具体的实现方式,并且可以学习如何手动检查模型 [^1]。 ### 降维方法 非负矩阵分解(NMF)是一种降维方法。从`sklearn.decomposition`中导入`NMF`,可创建实例`nmf = NMF(n_components,init,tol)`,其中`n_components`为主成分个数/降维后的维度,`init`为初始化方法,`tol`为最小迭代差值。通过`pca.fit_transform(data)`可进行降维计算并按行返回降维后的数据 [^4]。 ```python from sklearn.decomposition import NMF import numpy as np # 示例数据 data = np.random.rand(100, 20) # 创建NMF实例 nmf = NMF(n_components=5) # 降维计算 data_reduced = nmf.fit_transform(data) ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值