06 2020 档案
摘要:import torch import torch.nn.functional as F import matplotlib.pyplot as plt import numpy as np x = torch.linspace(-10,10,60) fig = plt.figure(figsize
阅读全文
摘要:我们可以看到绘制出来的图有四个边框,我们通过gca()对坐标轴进行一些简单处理,代码如下。 import torch import torch.nn.functional as F import matplotlib.pyplot as plt import numpy as np x = torc
阅读全文
摘要:本篇是摘抄pytorch-handbook里面的,有兴趣可以看看。 损失函数(Loss Function) 损失函数(loss function)是用来估量模型的预测值(我们例子中的output)与真实值(例子中的y_train)的不一致程度,它是一个非负实值函数,损失函数越小,模型的鲁棒性就越好。
阅读全文
摘要:import torch x = torch.rand(2,2) x1 = x.numpy() # torch转换到numpy x2 = torch.from_numpy(x1) #numpy转换torch print("\n torch_x:\n",x, "\n numpy_x1:\n",x1,
阅读全文
摘要:官方文档 首先我们要知道,lmplot是用来绘制回归图的。 让我们来看看他的API: seaborn.lmplot(x, y, data, hue=None, col=None, row=None, palette=None, col_wrap=None, height=5, aspect=1, m
阅读全文
摘要:看了一篇博客,感觉写的很棒:PyTorch 的 Autograd
阅读全文
摘要:运行这段代码 import torch import numpy as np import matplotlib.pyplot as plt x = torch.ones(2,2,requires_grad=True) print('x:\n',x) y = torch.eye(2,2,requir
阅读全文
摘要:output = torch.max(input, dim) input输入的是一个tensor dim是max函数索引的维度0/1,0是每列的最大值,1是每行的最大值 实例: import torch import numpy as np import matplotlib.pyplot as p
阅读全文
摘要:本篇借鉴了这篇文章,如果有兴趣,大家可以看看:https://blog.csdn.net/geter_CS/article/details/84857220 1、交叉熵:交叉熵主要是用来判定实际的输出与期望的输出的接近程度 2、CrossEntropyLoss()损失函数结合了nn.LogSoftm
阅读全文
摘要:看pytorch中文文档摘抄的笔记。 class torch.optim.SGD(params, lr=, momentum=0, dampening=0, weight_decay=0, nesterov=False)[source] 实现随机梯度下降算法(momentum可选)。 Nestero
阅读全文
摘要:import torch x = torch.randn(3, requires_grad=True) y = x*2 print(y.data.norm()) print(torch.sqrt(torch.sum(torch.pow(y,2)))) #其实就是对y张量L2范数,先对y中每一项取平方
阅读全文
摘要:学习数据酷客做的笔记,懒得自己打字,就截屏记录一下,方便以后回顾。
阅读全文
摘要:第一步安装nibabel,可以使用命令:pip install nibabel 之后: from nibabel.viewers import OrthoSlicer3D as osdimport nibabel as nib filename = 'image.nii' img = nib.loa
阅读全文
摘要:1、LinearRegression将方程分为两个部分存放,coef_存放回归系数,intercept_则存放截距,因此要查看方程,就是查看这两个变量的取值。 2、回归系数(regression coefficient)在回归方程中表示自变量x 对因变量y 影响大小的参数。回归系数越大表示x 对y
阅读全文
摘要:第一步:安装scipy,因为seaborn依赖scipy,如何安装scipy我之前有说过,可以看我之前安装sklearn库的过程中有安装scipy的方法。 第二步:pip install seaborn 第三步:import seaborn 第四步:没有错误,那就安装成功
阅读全文