set hlsearch set backspace=2 set ruler set showmode set nu setbg=dark set softtabstop=4 set shiftwidth=4 set fileencodings=utf-8,gbk,gb18030,gk2312 syntax on set showcmd set clipboard+=unnamed set cursorline set confirm set autoindent set cindent set expandtab set laststatus=2
(gdb) where #0 _rt0_amd64 () at /usr/lib/go/src/runtime/asm_amd64.s:15 #1 0x0000000000000001 in ?? () #2 0x00007fffffffdd2c in ?? () #3 0x0000000000000000 in ?? ()
# Search search: insight:true# you need to install `hexo-generator-json-content` before using Insight Search swiftype:# enter swiftype install key here baidu:false# you need to disable other search engines to use Baidu search
footer: # Specify the year when the site was setup. If not defined, current year will be used. #since: 2021
# Icon between year and copyright info. icon: # Icon name in Font Awesome. See: https://fontawesome.com/icons name: fa fa-heart # If you want to animate the icon, set it to true. animated: false # Change the color of icon, using Hex Code. color: "#ff0000"
# If not defined, `author` from Hexo `_config.yml` will be used. # Set to `false` to disable the copyright statement. copyright:
# Powered by Hexo & NexT powered: true
# Beian ICP and gongan information for Chinese users. See: https://beian.miit.gov.cn, http://www.beian.gov.cn beian: enable: false icp: # The digit in the num of gongan beian. gongan_id: # The full num of gongan beian. gongan_num: # The icon for gongan beian. See: http://www.beian.gov.cn/portal/download gongan_icon_url:
图片懒加载设置
在主题配置文件中启用 lazyload
1
copylazyload: true
设置代码块复制和代码高亮
在主题配置文件中修改 codeblock
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
codeblock: # Code Highlight theme # All available themes: https://theme-next.js.org/highlight/ theme: light: atom-one-dark dark: stackoverflow-dark prism: light: prism dark: prism-dark # Add copy button on codeblock copy_button: enable: true # Available values: default | flat | mac style: # Fold code block fold: enable: false height: 500
# Sidebar Avatar avatar: # Replace the default image and set the url here. url: /images/avatar.png # If true, the avatar will be displayed in circle. rounded: true # If true, the avatar will be rotated with the cursor. rotated: true
侧边栏社交链接
修改主题配置文件
1 2 3 4 5 6 7 8 9 10
social: GitHub: https://github.com/Qeuroal || fab fa-github #E-Mail: mailto:yourname@gmail.com || fa fa-envelope #Weibo: https://weibo.com/yourname || fab fa-weibo #Twitter: https://twitter.com/yourname || fab fa-twitter #FB Page: https://www.facebook.com/yourname || fab fa-facebook #StackOverflow: https://stackoverflow.com/yourname || fab fa-stack-overflow #YouTube: https://youtube.com/yourname || fab fa-youtube #Instagram: https://instagram.com/yourname || fab fa-instagram #Skype: skype:yourname?call|chat || fab fa-skype
在文章底部增加版权信息
编辑 主题配置文件,修改如下配置:
1 2 3 4 5 6 7 8 9 10
creative_commons: # Available values: by | by-nc | by-nc-nd | by-nc-sa | by-nd | by-sa | cc-zero license: by-nc-sa # Available values: big | small size: small sidebar: false post: true # You can set a language value if you prefer a translated version of CC license, e.g. deed.zh # CC licenses are available in 39 languages, you can find the specific and correct abbreviation you need on https://creativecommons.org language:
开启缓存
1 2 3
# Allow to cache content generation. Introduced in NexT v6.0.0. cache: enable: true
压缩
1 2
# Remove unnecessary files after hexo generate. minify: true
侧边栏显示分类条数
1 2
# Posts / Categories / Tags in sidebar. site_state: true
友链
1 2 3 4 5 6 7 8 9 10
# Blog rolls 友链 links_settings: icon: fa fa-link # 设置icon title: 友情链接 # 设置标题 # Available values: block | inline layout: block # css样式,是一行一条,还是自动换行
# Local Search # Dependencies: https://github.com/next-theme/hexo-generator-searchdb local_search: enable: true # If auto, trigger search by changing input. # If manual, trigger search by pressing enter key or search button. trigger: auto # Show top n results per article, show all results by setting to -1 top_n_per_article: 1 # Unescape html strings to the readable one. unescape: false # Preload the search data when the page loads. preload: false
A tensor is the primary data structure used by neural networks.
官方定义2
A PyTorch Tensor is conceptually identical to a numpy array: a Tensor is an n-dimensional array, and PyTorch provides many functions for operating on these Tensors.
通俗理解
多维数组(Tensors and nd-arrays are the same thing! So tensors are multidimensional arrays or nd-arrays for short.)
Indexes required
Computer science
Mathematics
n
nd-array
nd-tensor
A scalar is a $0$ dimensional tensor
A vector is a $1$ dimensional tensor
A matrix is a $2$ dimensional tensor
A nd-array is an $n$ dimensional tensor
拓展
We often see this kind of thing where different areas of study use different words for the same concept.
索引
obvious: 访问一个多维数组, 需要几个索引
秩
即维数,或者说在张量中访问一个元素,需要的索引数
A tensor’s rank tells us how many indexes are needed to refer to a specific element within the tensor.
轴
An axis of a tensor is a specific dimension of a tensor.
tensor 属性
torch.dtype
Data type
dtype
CPU tensor
GPU tensor
32-bit floating point
torch.float32
torch.FloatTensor
torch.cuda.FloatTensor
64-bit floating point
torch.float64
torch.DoubleTensor
torch.cuda.DoubleTensor
16-bit floating point
torch.float16
torch.HalfTensor
torch.cuda.HalfTensor
8-bit integer (unsigned)
torch.uint8
torch.ByteTensor
torch.cuda.ByteTensor
8-bit integer (signed)
torch.int8
torch.CharTensor
torch.cuda.CharTensor
16-bit integer (signed)
torch.int16
torch.ShortTensor
torch.cuda.ShortTensor
32-bit integer (signed)
torch.int32
torch.IntTensor
torch.cuda.IntTensor
64-bit integer (signed)
torch.int64
torch.LongTensor
torch.cuda.LongTensor
torch.device
类型
CPU
GPU
指定GPU
1
device = torch.device('cuda:0')
注意
One thing to keep in mind about using multiple devices is that tensor operations between tensors must happen between tensors that ==exists on the same device==.
To backpropagate the error all we have to do is to loss.backward(). You need to clear the existing gradients though, ==else gradients will be accumulated to existing gradients.==
[root@iZbp16w4b9baac6xlzfcdmZ home]# ls admin [root@iZbp16w4b9baac6xlzfcdmZ home]# touch f1 # 创建一个f1文件 [root@iZbp16w4b9baac6xlzfcdmZ home]# ls admin f1 [root@iZbp16w4b9baac6xlzfcdmZ home]# ln f1 f2 # 创建一个硬链接f2 [root@iZbp16w4b9baac6xlzfcdmZ home]# ls admin f1 f2 [root@iZbp16w4b9baac6xlzfcdmZ home]# ln -s f1 f3 # 创建一个软链接(符号链接)f3 [root@iZbp16w4b9baac6xlzfcdmZ home]# ls admin f1 f2 f3 [root@iZbp16w4b9baac6xlzfcdmZ home]# echo "hello" >> f1 # 给f1文件中写入一段字符串 [root@iZbp16w4b9baac6xlzfcdmZ home]# ls admin f1 f2 f3 [root@iZbp16w4b9baac6xlzfcdmZ home]# cat f1 hello [root@iZbp16w4b9baac6xlzfcdmZ home]# cat f2 hello [root@iZbp16w4b9baac6xlzfcdmZ home]# ls admin f1 f2 f3 [root@iZbp16w4b9baac6xlzfcdmZ home]# cat f3 hello
删除f1后,查看 f2 和 f3 的区别:
1 2 3 4 5 6 7
[root@iZbp16w4b9baac6xlzfcdmZ home]# rm -rf f1 [root@iZbp16w4b9baac6xlzfcdmZ home]# ls admin f2 f3 [root@iZbp16w4b9baac6xlzfcdmZ home]# cat f2 # f2硬链接还在 hello [root@iZbp16w4b9baac6xlzfcdmZ home]# cat f3 # f3(软连接、符号链接)快捷方式失效 cat: f3: No such file or directory
注意:只要源文件发生改变,链接文件也会发生改变
硬连接
硬连接指通过索引节点来进行连接。在 Linux 的文件系统中,保存在磁盘分区中的文件不管是什么类型都给它分配一个编号,称为索引节点号(Inode Index)。在 Linux 中,多个文件名指向同一索引节点是存在的。比如:A 是 B 的硬链接(A 和 B 都是文件名),则 A 的目录项中的 inode 节点号与 B 的目录项中的 inode 节点号相同,即一个 inode 节点对应两个不同的文件名,两个文件名指向同一个文件,A 和 B 对文件系统来说是完全平等的。删除其中任何一个都不会影响另外一个的访问。
另外一种连接称之为符号连接(Symbolic Link),也叫软连接。软链接文件有类似于 Windows 的快捷方式。它实际上是一个特殊的文件。在符号连接中,文件实际上是一个文本文件,其中包含的有另一文件的位置信息。比如:A 是 B 的软链接(A 和 B 都是文件名),A 的目录项中的 inode 节点号与 B 的目录项中的 inode 节点号不相同,A 和 B 指向的是两个不同的 inode,继而指向两块不同的数据块。但是 A 的数据块中存放的只是 B 的路径名(可以根据这个找到 B 的目录项)。A 和 B 之间是“主从”关系,如果 B 被删除了,A 仍然存在(因为两个是不同的文件),但指向的是一个无效的链接。
测试:
1 2 3 4 5 6 7 8 9 10
[root@qeuroal /]# cd /home [root@qeuroal home]# touch f1 # 创建一个测试文件f1 [root@qeuroal home]# ls f1 [root@qeuroal home]# ln f1 f2 # 创建f1的一个硬连接文件f2 [root@qeuroal home]# ln -s f1 f3 # 创建f1的一个符号连接文件f3 [root@qeuroal home]# ls -li # -i参数显示文件的inode节点信息 397247 -rw-r--r-- 2 root root 0 Mar 13 00:50 f1 397247 -rw-r--r-- 2 root root 0 Mar 13 00:50 f2 397248 lrwxrwxrwx 1 root root 2 Mar 13 00:50 f3 -> f1
从上面的结果中可以看出,硬连接文件 f2 与原文件 f1 的 inode 节点相同,均为 397247,然而符号连接文件的 inode 节点不同。
1 2 3 4 5 6 7 8 9 10 11 12 13
# echo 字符串输出 >> f1 输出到 f1文件 [root@qeuroal home]# echo "I am f1 file" >>f1 [root@qeuroal home]# cat f1 I am f1 file [root@qeuroal home]# cat f2 I am f1 file [root@qeuroal home]# cat f3 I am f1 file [root@qeuroal home]# rm -f f1 [root@qeuroal home]# cat f2 I am f1 file [root@qeuroal home]# cat f3 cat: f3: No such file or directory
通过上面的测试可以看出:当删除原始文件 f1 后,硬连接 f2 不受影响,但是符号连接 f1 文件无效;
依此您可以做一些相关的测试,可以得到以下全部结论:
删除符号连接f3,对f1,f2无影响;
删除硬连接f2,对f1,f3也无影响;
删除原文件f1,对硬连接f2没有影响,导致符号连接f3失效;
同时删除原文件f1,硬连接f2,整个文件会真正的被删除。
Vim编辑器
简介
Vim是从 vi 发展出来的一个文本编辑器。代码补完、编译及错误跳转等方便编程的功能特别丰富,在程序员中被广泛使用。尤其是Linux中,必须要会使用vim:查看内容、编辑内容、保存内容。
Shell是用户与Linux系统之间的接口。Linux的Shell有许多种,每种都有不同的特点。常用的有sh(Bourne Shell), csh(C Shell), ksh(Korn Shell), tcsh(TENEX/TOPS-20 type C Shell), bash(Bourne Again Shell)等。