/usr/local/lib64/python3.6/site-packages/torch/nn/__pycache__
NameSizeModeActions
common_types.cpython-36.pyc9900644editdlrm
cpp.cpython-36.pyc34600644editdlrm
functional.cpython-36.pyc1616480644editdlrm
grad.cpython-36.pyc118400644editdlrm
init.cpython-36.pyc175510644editdlrm
parameter.cpython-36.pyc75680644editdlrm
_reduction.cpython-36.pyc12440644editdlrm
__init__.cpython-36.pyc20020644editdlrm
Edit: /usr/local/lib64/python3.6/site-packages/torch/nn/__pycache__/grad.cpython-36.pyc (11840B)
3 Eg6@srdZddlZddlmZmZmZddlZdddZdddZdd d Z dd d Z dd dZ dddZ dddZ dS)zGradient interfaceN)_single_pair_triplec s dkr tjddgttjd}t|dkrR| dt|krvtdj|dtfddfddt|Dfd dt|D}xJt|D]:\}} } || ks|| krtd j|j ddqWt fd d t|DS) NzK_grad_input_padding 'dilation' argument not provided. Default of 1 is used.rz)input_size must have {} elements (got {})cs>j|dd|d|d||dS)Nrr)size)d)dilation grad_output kernel_sizepaddingstride9/usr/local/lib64/python3.6/site-packages/torch/nn/grad.pydim_sizesz%_grad_input_padding..dim_sizecsg|] }|qSrr).0r)rrr sz'_grad_input_padding..cs g|]}||dqS)rr)rr) min_sizesr rrrszarequested an input grad size of {}, but valid sizes range from {} to {} (for a grad_output of {})c3s|]}||VqdS)Nr)rr) input_sizerrr %sz&_grad_input_padding..) warningswarnlenlistdim ValueErrorformatrangeziprtuple) r rr r r r kZ max_sizesrZmin_sizemax_sizer)r rr rr rr r r_grad_input_paddings(   r"c Cs^t|}t|}t|}|jdg}|dkr4tdt||||||}tj||d|||||S)a Computes the gradient of conv1d with respect to the input of the convolution. This is same as the 1D transposed convolution operator under the hood but requires the shape of the gradient w.r.t. input to be specified explicitly. Args: input_size : Shape of the input gradient tensor weight: weight tensor (out_channels x in_channels/groups x kW) grad_output : output gradient tensor (minibatch x out_channels x oW) stride (int or tuple, optional): Stride of the convolution. Default: 1 padding (int or tuple, optional): Zero-padding added to both sides of the input. Default: 0 dilation (int or tuple, optional): Spacing between kernel elements. Default: 1 groups (int, optional): Number of blocked connections from input channels to output channels. Default: 1 Examples:: >>> input = torch.randn(1,1,3, requires_grad=True) >>> weight = torch.randn(1,1,1, requires_grad=True) >>> output = F.conv1d(input, weight) >>> grad_output = torch.randn(output.shape) >>> grad_input = torch.autograd.grad(output, input, grad_output) >>> F.grad.conv1d_input(input.shape, weight, grad_output) rNz3grad.conv1d_input requires specifying an input_size)rshaperr"torchZconv_transpose1d) rweightr r r r groupsr grad_input_paddingrrr conv1d_input(s  r(c Cst|}t|}t|}|jd}|jd}|jd} |jjd||d}|jj|jd|jdd|jd}|jjd|jd|jd|jd}tj||d||||| } | jj| | jd| | jd} | jddj|||| jdjddj dd|dS)a! Computes the gradient of conv1d with respect to the weight of the convolution. Args: input: input tensor of shape (minibatch x in_channels x iW) weight_size : Shape of the weight gradient tensor grad_output : output gradient tensor (minibatch x out_channels x oW) stride (int or tuple, optional): Stride of the convolution. Default: 1 padding (int or tuple, optional): Zero-padding added to both sides of the input. Default: 0 dilation (int or tuple, optional): Spacing between kernel elements. Default: 1 groups (int, optional): Number of blocked connections from input channels to output channels. Default: 1 Examples:: >>> input = torch.randn(1,1,3, requires_grad=True) >>> weight = torch.randn(1,1,1, requires_grad=True) >>> output = F.conv1d(input, weight) >>> grad_output = torch.randn(output.shape) >>> grad_weight = torch.autograd.grad(output, filter, grad_output) >>> F.grad.conv1d_weight(input, weight.shape, grad_output) rrrN)r) rr# contiguousrepeatviewr$Zconv1dsum transposenarrow) input weight_sizer r r r r& in_channels out_channels min_batch grad_weightrrr conv1d_weightQs$       r5c Csft|}t|}t|}|jd|jdf}|dkr>> input = torch.randn(1,1,3,3, requires_grad=True) >>> weight = torch.randn(1,1,1,2, requires_grad=True) >>> output = F.conv2d(input, weight) >>> grad_output = torch.randn(output.shape) >>> grad_input = torch.autograd.grad(output, input, grad_output) >>> F.grad.conv2d_input(input.shape, weight, grad_output) rNz3grad.conv2d_input requires specifying an input_size)rr#rr"r$Zconv_transpose2d) rr%r r r r r&r r'rrr conv2d_inputs r7c Cs>t|}t|}t|}|jd}|jd}|jd} |jjd||dd}|jj|jd|jdd|jd|jd}|jjd|jd|jd|jd|jd}tj||d||||| } | jj| | jd| | jd| jd} | jddj|||| jd| jdjddj dd|dj dd|dS)a/ Computes the gradient of conv2d with respect to the weight of the convolution. Args: input: input tensor of shape (minibatch x in_channels x iH x iW) weight_size : Shape of the weight gradient tensor grad_output : output gradient tensor (minibatch x out_channels x oH x oW) stride (int or tuple, optional): Stride of the convolution. Default: 1 padding (int or tuple, optional): Zero-padding added to both sides of the input. Default: 0 dilation (int or tuple, optional): Spacing between kernel elements. Default: 1 groups (int, optional): Number of blocked connections from input channels to output channels. Default: 1 Examples:: >>> input = torch.randn(1,1,3,3, requires_grad=True) >>> weight = torch.randn(1,1,1,2, requires_grad=True) >>> output = F.conv2d(input, weight) >>> grad_output = torch.randn(output.shape) >>> grad_weight = torch.autograd.grad(output, filter, grad_output) >>> F.grad.conv2d_weight(input, weight.shape, grad_output) rrrr6N)r) rr#r)r*r+r$Zconv2dr,r-r.) r/r0r r r r r&r1r2r3r4rrr conv2d_weights,       r8c Csnt|}t|}t|}|jd|jd|jdf}|dkrDtdt||||||}tj||d|||||S)a Computes the gradient of conv3d with respect to the input of the convolution. This is same as the 3D transposed convolution operator under the hood but requires the shape of the gradient w.r.t. input to be specified explicitly. Args: input_size : Shape of the input gradient tensor weight: weights tensor (out_channels x in_channels/groups x kT x kH x kW) grad_output : output gradient tensor (minibatch x out_channels x oT x oH x oW) stride (int or tuple, optional): Stride of the convolution. Default: 1 padding (int or tuple, optional): Zero-padding added to both sides of the input. Default: 0 dilation (int or tuple, optional): Spacing between kernel elements. Default: 1 groups (int, optional): Number of blocked connections from input channels to output channels. Default: 1 Examples:: >>> input = torch.randn(2, 8, 10, 10, 20, requires_grad=True) >>> weight = torch.randn(4, 8, 2, 3, 3, requires_grad=True) >>> output = F.conv3d(input, weight) >>> grad_output = torch.randn(output.shape) >>> grad_input = torch.autograd.grad(output, input, grad_output) >>> F.grad.conv3d_input(input.shape, weight, grad_output) rr6Nz3grad.conv3d_input requires specifying an input_size)rr#rr"r$Zconv_transpose3d) rr%r r r r r&r r'rrr conv3d_inputs r:c Csjt|}t|}t|}|jd}|jd}|jd} |jd||ddd}|jj|jd|jdd|jd|jd|jd}|jjd|jd|jd|jd|jd|jd}tj||d||||| } | jj| | jd| | jd| jd| jd} | jddj|||| jd| jd| jdjddj dd|dj dd|dj dd|dS)aH Computes the gradient of conv3d with respect to the weight of the convolution. Args: input: input tensor of shape (minibatch x in_channels x iT x iH x iW) weight_size : Shape of the weight gradient tensor grad_output : output gradient tensor (minibatch x out_channels x oT x oH x oW) stride (int or tuple, optional): Stride of the convolution. Default: 1 padding (int or tuple, optional): Zero-padding added to both sides of the input. Default: 0 dilation (int or tuple, optional): Spacing between kernel elements. Default: 1 groups (int, optional): Number of blocked connections from input channels to output channels. Default: 1 Examples:: >>> input = torch.randn(2, 8, 10, 10, 20, requires_grad=True) >>> weight = torch.randn(4, 8, 2, 3, 3, requires_grad=True) >>> output = F.conv3d(input, weight) >>> grad_output = torch.randn(output.shape) >>> grad_weight = torch.autograd.grad(output, weight, grad_output) >>> F.grad.conv3d_weight(input, weight.shape, grad_output) rrrr6r9N)r) rr#r*r)r+r$Zconv3dr,r-r.) r/r0r r r r r&r1r2r3r4rrr conv3d_weights.      r;)N)rrrr)rrrr)rrrr)rrrr)rrrr)rrrr)__doc__r$Z modules.utilsrrrrr"r(r5r7r8r:r;rrrrs ) 0 ) 4 )