常用函数

  1. torch.norm() 求范数函数,p参数为指明0 1 2范数,dim参数为指明矩阵范数还是矢量范数
  2. torch.clamp() 限制张量范围上下限
  3. torch.prod(input, dim, keepdim=False, dtype=None) → Tensor
    Returns the product of each row of the input tensor in the given dimension dim.
    dim 要减少的维度
    keepdim (bool) – whether the output tensor has dim retained or not.
  4. torch.where(condition, x, y) → Tensor
    Return a tensor of elements selected from either x or y, depending on condition.

如何使用Dataloader加载自己的数据集

详细请点击这里
1.自己创建的数据集类首先继承Dataset类,然后在类里重写两个函数:

def __getitem__(self, index):
def __len__(self):

2.自定义一个collate_fn函数,传入DataLoader里面

def collate_fn(batch):

LSTM实践与理论结合:

一个很牛逼的参考博客,一看解千愁

在单层单向LSTM中,其outputs其实就是每一个timestep产生的h_t拼接起来的,而h_n则是LSTM最后h_t,其中outputs[-1,:,:] 就等于h_n[-1,:,:]

LSTM

这一段话让我如梦初醒,解决了困扰我很久的问题

python日志模块logging的用法

logging介绍
argparse参数详解

seed() 和torch中manual_seed的作用

seed详解

python中的几种矩阵乘法 np.dot, np.multiply, *

np.dot() :对于二维矩阵,计算真正意义上的矩阵乘积,同线性代数中矩阵乘法的定义。对于一维矩阵,计算两者的内积。
np.multiply(), 或 * : element-wise product. 实现对应元素相乘,有2种方式,一个是np.multiply(),另外一个是*。
具体示例请参考此博客

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值