- 博客(16)
- 收藏
- 关注
转载 sklearn---onehotcode
非常好的文章https://www.cnblogs.com/zhoukui/p/9159909.html
2019-08-16 22:45:05 213
原创 jieba
1. # encoding=utf-8 import jieba import jieba.posseg as pseg print("\njieba分词全模式:") seg_list = jieba.cut("我来到北京清华大学", cut_all=True) print("Full Mode: " + "/、 ".join(seg_list)) # 全模式 strings="是广泛...
2019-08-15 01:29:19 197
原创 pytorch-7交叉商1
定义: def cross_entropy(input, target, weight=None, size_average=None, ignore_index=-100, reduce=None, reduction='mean'): # type: (Tensor, Tensor, Optional[Tensor], Optional[boo...
2019-08-01 21:16:28 231
原创 pytorch-6线性优化
1.可视化,meshgrid合并x,y def fun(x): return (x[0]**2+x[1]-11)**2+(x[0]+x[1]**2-7)**2 x=np.arange(-6,6,0.1) y=np.arange(-6,6,0.1) X,Y=np.meshgrid(x,y) print(X.shape) print(Y.shape) Z=fun([X,Y]) fig=p...
2019-08-01 20:53:02 172
原创 pytorch5求导
import torch from torch.nn import functional x=torch.ones(1,requires_grad=True) print(x) w=torch.full([1],6,requires_grad=True) mse=functional.mse_loss(x,x*w) print(mse)#(1-6)**2 print(torch.autograd...
2019-08-01 00:32:03 106
原创 pytorch基础学习5
1.where import torch cond=torch.tensor([[0.6,0.4],[0.7,0.3]]) a=torch.tensor([[0.,0.],[0.,0.]]) b=torch.tensor([[1.,1.],[1.,1.]]) c=torch.where(cond>0.5,a,b) print(a) print(b) print(c) 结果:tensor...
2019-07-31 22:15:26 105
原创 pytourch基础学习4
1.matmul/@/mm(二维)矩阵相乘 import torch a=torch.randn(4,2,3,8) b=torch.randn(4,2,8,8) print(torch.matmul(a,b).shape) 结果:torch.Size([4, 2, 3, 8]) 2.pow/** import torch a=torch.full([2,2],9) print(a) b...
2019-07-31 21:21:00 308
原创 pytourch基础学习3
1.合并 import torch a=torch.randn(5,2,3,8) b=torch.randn(4,2,3,8) print(torch.cat([a,b],dim=0).shape) 结果:torch.Size([9, 2, 3, 8]) 2.stack增加维度 import torch a=torch.randn(4,2,3,8) b=torch.randn(4,2,...
2019-07-31 20:31:07 236
原创 pytorch基础学习2
1.切片 import torch b=torch.tensor([[[1, 2, 3,4]]]) print(b) a=b[:,:,0:4:2].shape print(a) print(b[:,:,0:4:2]) print(b) 结果:tensor([[[1, 2, 3, 4]]]) torch.Size([1, 1, 2]) tensor([[[1, 3]]]) tensor([[[...
2019-07-30 14:22:51 91
原创 pytorch基础学习1
1.从numpy导入 import torch import numpy as np a=np.array([2,2.3]) b=torch.from_numpy(a) print(a) print(b) a=np.ones([2,3]) b=torch.from_numpy(a) print(a) print(b) 结果:[2. 2.3] tensor([2.0000, 2.3000],...
2019-07-30 13:00:38 97
原创 sklearn
from sklearn import datasets from sklearn.linear_model import LinearRegression import numpy as np import matplotlib.pyplot as plt data=datasets.load_boston() data_x=data.data data_y=data.target model...
2019-07-07 16:25:27 77
转载 逻辑回归,凸函数
原文链接:https://www.jianshu.com/p/894bda167422 https://tech.meituan.com/2015/05/08/intro-to-logistic-regression.html https://blog.csdn.net/Julialove102123/article/details/78405261 写文章注册登录 首页 下载App...
2019-07-07 16:08:14 1633
转载 线性回归3
coding=utf-8 线性回归-单特征梯度下降练习 from numpy import * import matplotlib.pyplot as plt from matplotlib import animation import numpy as np 【1】特征缩放 X:=[X-mean(X)]/std(X) || X:=[X-min(X)]/max(X)-min(X) ; def f...
2019-07-06 18:03:46 152
原创 线性回归2
1.特征放缩 对于多特征的线性回归,为了平衡各特征之间的权重,采用特征放缩 eg:size(0-2000)1000-平均值 bedroom(1-5)2-平均值 2.梯度下降法是否运行正确 画出代价函数和步数的关系图 3.学习率 0.001,0.003,0.01,0.03,0.1,..... ...
2019-07-06 17:57:08 104
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人