nn.Linear & Tensor.masked_fill

1. nn.Linear

  • torch.nn.Linear(in_features, out_features, bias=True, device=None, dtype=None)

    • Applies a linear transformation to the incoming data: y = x A T + b y = xA^T + b y=xAT+b
    • This module supports TensorFloat32.
    • On certain ROCm devices, when using float16 inputs this module will use different precision for backward.
  • Parameters

    • in_features – size of each input sample
    • out_features – size of each output sample
    • bias – If set to False, the layer will not learn an additive bias. Default: True
  • Shape:

    • Input: ( ∗ , H i n ) (*, H_{in}) (,Hin), where * means any number of dimensions including none and H i n = in_features H_{in} = \text{in\_features} Hin=in_features
    • Output: ( ∗ , H o u t ) (*, H_{out}) (,Hout), where all but the last dimension are the same shape as the input and H o u t = out_features H_{out} = \text{out\_features} Hout=out_features

2. Tensor.masked_fill

Tensor.masked_fill_(mask, value)

Fills elements of self tensor with value where mask is True. The shape of mask must be broadcastable with the shape of the underlying tensor.

  • Parameters
    • mask (BoolTensor) – the boolean mask
    • value (float) – the value to fill in with
  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值