Ridge-Regression

https://youtu.be/Q81RR3yKn30

例子

数据集里面,训练集训出来的模型在测试集上效果不好。这是因为数据没有很好的代表性,把斜率带偏了。

所以要把模型调整一下

具体例子

在这个例子里面,通过加上正则项,使得最后的结果斜率更低。

作用原理解释

如果是参数比较大,自变量的变化会导致因变量变化很大。所以要对参数限制。

得到的模型斜率比较低,所以预测结果对于斜率的敏感性比较低。

在ridge regression里面,如果要求截距也是很小,就会导致0点处基本为0。所以不会这样要求。

数据个数说明

普通的线性回归的数据量应该大于参数量,但是用Ridge Regression可以在数据量很少的时候进行计算。

偏差(bias)方差(variance)

https://youtu.be/EuBBz3bI-aA

数据点里面,蓝色表示训练集,绿色表示测试集,中间的曲线表示ground truth。

数据

Bias:The inability for a machine learing method to capture the true relationship is called bias. 无法捕获真实关系

线性模型怎样都不能拟合数据,所以bias比较大。

线性模型

波浪线可以很好地拟合数据点,所以bias很小。

波浪线模型

但是如果考虑测试集,会发现测试集上反而是线性模型更好一些。

在不同数据集上的表现差异是variance。下面的图就说明overfit了。

Variance

方差比较大的模型,在新的数据上面的表现不确定。

西瓜书上的数学定义

CS224W-03-1-2021

https://www.bilibili.com/video/BV1RZ4y1c7Co?p=7

传统的ML,输入图之后,获取一些特征描述拓扑特征,并将属性信息输入,一起进行预测。

需要创建structured features,并用学习算法。

获取特征的过程:feature engineering。所以要研究怎么摆脱:用表示学习representation learning,不用人工获取特征。

要进行高效的、和任务无关的表示学习,每个node映射到一个vector(feature representation、embedding),维度d。

similarity of embeddings of nodes show similarity of nodes in the network。

downstream tasks:

windows-gcc

下载cygwin

https://cygwin.com/

安装

安装的时候记得搜索gcc进行安装。现在安装了mingw64-x86_64-gcc-g++ 、gcc-g++、vim、wget等常用的

参考:

添加环境变量

PATH中添加C:\cygwin64\bin

gcc、g++使用

mingw64的:

1
2
3
4
5
6
7
8
9
10
11
// 32-bit Windows
$ i686-w64-mingw32-gcc --version
i686-w64-mingw32-gcc (GCC) 6.4.0
$ i686-w64-mingw32-g++ --version
i686-w64-mingw32-g++ (GCC) 6.4.0

// 64-bit Windows
$ x86_64-w64-mingw32-gcc --version
x86_64-w64-mingw32-gcc (GCC) 6.4.0
$ x86_64-w64-mingw32-g++ --version
x86_64-w64-mingw32-g++ (GCC) 6.4.0

普通的直接用gcc g++就行

cmake

cmake . -G "Unix Makefiles" 或者 cmake . -G "MinGW Makefiles"

(最好先创建一个build目录,在build目录中cmake .. -G "Unix Makefiles")

nginx-centos

安装

下载:sudo yum install nginx

开机启动:sudo systemctl enable nginx

文件在/etc/nginx/nginx.conf,对其进行修改,将file.xxxx.top转发到8002,将blog.xxxx.top转发到8003

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

events {
worker_connections 1024;
}

http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log /var/log/nginx/access.log main;

sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;

include /etc/nginx/mime.types;
default_type application/octet-stream;

include /etc/nginx/conf.d/*.conf;

server {
listen 80;
server_name file.xxxx.top;

location / {
proxy_pass http://127.0.0.1:8002;
proxy_set_header Host $proxy_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}

server {
listen 80;
server_name blog.xxxx.top;

location / {
proxy_pass http://127.0.0.1:8003;
proxy_set_header Host $proxy_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
}

启动:sudo systemctl start nginx

cuda安装报错信息踩坑

如果是安装的时候有报错,并且/var/log/cuda-installer.log中写的是[ERROR]: Install of driver component failed.,就**记得看一下/var/log/nvidia-installer.log**。不一定是因为已经装了多个版本cuda的原因,可能是X service等原因! https://forums.developer.nvidia.com/t/info-finished-with-code-256-error-install-of-driver-component-failed/107661/6

X service error问题

https://blog.csdn.net/lien0906/article/details/54312166

命令行模式下用 sudo init 3

注:这个报错信息是:You appear to be running an X server; please exit X before installing

多个显卡驱动

https://blog.csdn.net/weixin_41010198/article/details/109367449

可以用sudo apt-get purge nvidia* 删除旧的,再把cuda旧版本的安装包手动删除

空间不足

如果是刚开始安装提示空间不足或者安装包损坏,用md5sum确认安装包没有问题的话,就可以用 sudo sh xxx.run --tmpdir=路径换一下安装的临时文件路径。注意是tmpdir不是tempdir

如果后面安装出错提示空间不足(log记录中或者直接提示),就可以用df看看安装路径下面的盘是不是满了 https://www.sohu.com/a/223172587_495675

cuda清华源

https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/

https://www.jianshu.com/p/5df0c6b541eb

可以直接改配置文件。

手动输入的话,输入下面这几个,还需要添加channel:

1
2
3
4
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free 
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2

添加channel

可以直接打开https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/ 看有哪些channel,比如pytorch的添加可以用conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch