『PyTorch』学习笔记
two types of data
dataset
dataloader
dataset
Provide a way to get data and its label
dataloader
为后面的网络提供不同的数据形式
dataset practice
Dataset from torch.utils.data is a abstract class. We should create a subclass of it.
from torch.utils.data import Datasetfrom PIL import Imageimport osclass MyData(Dataset): def __init__(self, root_dir, label_dir): self.root_dir = root_dir self.label_dir = label_dir self.path = os.path.join(self.root_dir, self.label_dir) self.img_path ...
记一次模型训练CIFAR10
Introduction
采用数据集CIFAR10,网络模型如下:
Code
代码如下,分别是网络模型和训练代码
from torch import nnimport torchclass Tudui(nn.Module): def __init__(self): super(Tudui, self).__init__() self.model = nn.Sequential( nn.Conv2d(3, 32, 5, 1, 2), nn.MaxPool2d(2), nn.Conv2d(32, 32, 5, 1, 2), nn.MaxPool2d(2), nn.Conv2d(32, 64, 5, 1, 2), nn.MaxPool2d(2), nn.Flatten(), nn.Linear(64 * 4 * 4, 64), nn.Linear(64, 10) ...
Mac通过脚本批量去除文件前缀
Introduction
从b站下载的视频,文件名前面有很长一段标题,想要去除,于是问了chatgpt,得到以下脚本,亲测好使。
#!/bin/bashfor filename in *; do newname=$(echo "$filename" | sed 's/^PyTorch深度学习快速入门教程(绝对通俗易懂!)【小土堆】 - //') mv "$filename" "$newname"done
代码解释
#!/bin/bash指定代码解释器
for循环:由do和done包裹。
sed:使用s/old/new/进行替换操作,将所有old字符串识别,替换成new。
本例中old为PyTorch深度学习快速入门教程(绝对通俗易懂!)【小土堆】 - 。前面的^是正则表达式,表示行的开头,这样就可以替换行起始位置的字符串。
机器学习应用建议
When we test our hypothesis on a new sets of data samples, we find that it makes unacceptably large error in its predictions. We can try:
Get more training examples
Try smaller sets of features
Try getting additional features
Try adding polynomial features
Try decreasing/increasing λ\lambdaλ
But it’s hard to say a certain attempt will always work, so we have to try different types of improving.
Machine learning diagnostic
Diagnostic: A test that you can run to gain insight what is/isn’t worki ...
神经网络基本介绍
Neural network
Problems of too many features
If we wan to create a hypothesis consisting of all squares terms and cross terms, it will be an extremely complex function. For instance:
For computer vision, if we want to recognize a picture of 50 * 50px, there will be 2500 pixels. Then if we utilize every cross terms like xi×xjx_i \times x_jxi×xj , there will be 300, 000 features.
origin of neural network
Algorithms that try to mimic the brain.
Very widely used in 80s and early 90s; popularity di ...
「python」常用语法和函数
文件操作
读取.mat数据集
.mat means the data has been saved in a native Octave or Matlab matrix format. But powerful python can read it by using the loadmat function within the scipy.io module. Then it returns a dictionary字典,键值对
组合路径
import osos.path.join("Data", "dataset1")
Data is the name of folder, dataset1 is the name of the file.
索引方法
For array of numpy, we can use either y[0, 0] or y[0][0] to index the value.
For array not of numpy, we can only use y[0][0] to index the element.
...
「python」理解面向过程和面向对象
面向过程
专注于实现功能的每一个步骤。
例如给定事件:洗衣服
put(detergent, washing_machine)put(clothes, washing_machine)start(washing_machine)wash(washing_machine, clothes)dry(washing_machine, clothes)
是编年体
编年体是一种按照年代顺序编写的历史记载形式。它通常按照年份或历代统治者的顺序,按照时间线的方式来叙述历史事件。编年体的作品通常简洁明了,注重事实的记录,不过多描写人物的思想和情感。编年体的代表作品有《史记》和《汉书》等。
面向对象
理解概念
class human: def put(self, be_put, to): ... def start(self, machine): ...class washing_machine: def wash(self, be_washed): ... def dry(self, be_dried): ...
是纪传体
纪传体是一种以人物为中心,按照人物的生平经 ...
机器学习笔记_基础
application examples of machine learning
Database mining 数据挖掘
让计算机学习操作, 规划
手写识别
自然语言处理
计算机视觉
个性化推荐
Samuel 通过与计算机下棋, 让计算机学会了下棋. 并且比Samuel下得还好.
TEP理论
T: task 让计算机完成的任务内容. 给邮件分类, 是否垃圾邮件
E: experience 让计算机观察学习人类是如何给邮件分类的.
P: performance measure 性能测试. 看看计算机给邮件分类的效果如何, 正确率多少.
algorithms
supervised learning
unsupervised learning
有监督学习: 教计算机干活.
例如我们想预测, 即让计算机拟合直线/二次曲线, 需要先给他一个数据集data set, 里面包含了正确答案. 计算机以此产生出更多的正确答案.
一种形式被称为regression回归问题. 得出的是拟合的线的表达式, 可以得出线上任意一点的值 real-valued
另一种是classsification 分类 ...
「已解决」Github SSH密钥无法绑定
Introduction
在windows上尝试给github绑定SSH密钥,已经在github设置中成功添加,但每次git push均无法验证成功。探索后认为是由于密钥格式以及长度等信息不符合要求,所以重新生成密钥,专门对github进行SSH验证。
重新生成密钥
ssh-keygen -t rsa -b 4096 -f ~/.ssh/id_rsa_github
命令说明:
ssh-keygen 生成密钥
-t rsa 指定密钥类型为rsa
-b 4096 指定密钥长度为4096
-f ~/.ssh/id_rsa_github 保存位置和文件名称
修改config
修改~/.ssh/config文件,存在多个密钥时,指定使用哪个密钥
Host github.com IdentityFile ~/.ssh/id_rsa_github # 指定用这个密钥去验证 IdentitiesOnly yes # 不尝试任何其他密钥(可选)
Hello World
Welcome to Hexo! This is your very first post. Check documentation for more info. If you get any problems when using Hexo, you can find the answer in troubleshooting or you can ask me on GitHub.
Quick Start
Create a new post
$ hexo new "My New Post"
More info: Writing
Run server
$ hexo server
More info: Server
Generate static files
$ hexo generate
More info: Generating
Deploy to remote sites
$ hexo deploy
More info: Deployment







