Collection
extension Collection where Element: DynamicGraph.AnyTensor
extension Collection where Element: DynamicGraph.AnyGroup
extension Collection where Element == Tensor<Float64>
extension Collection where Element == Tensor<Int64>
extension Collection where Element == Tensor<Float32>
extension Collection where Element == Tensor<Int32>
extension Collection where Element == Tensor<Float16>
extension Collection where Element == Tensor<UInt8>
-
Compute gradients from this tensor to the source tensors.
Declaration
Swift
public func backward<S: Sequence>(to tensors: S, streamContext: StreamContext? = nil) where S.Element: DynamicGraph.AnyTensor
Parameters
to
The source tensors to this tensor.
streamContext
The stream context to perform such operation.
-
Compute gradients from this tensor to the source tensor.
Declaration
Swift
public func backward(to tensor: DynamicGraph.AnyTensor, streamContext: StreamContext? = nil)
Parameters
to
The source tensor to this tensor.
streamContext
The stream context to perform such operation.
-
Compute gradients from this tensor to the source tensors.
Declaration
Swift
public func backward<S: Sequence>(to tensors: S, streamContext: StreamContext? = nil) where S.Element: DynamicGraph.AnyGroup
Parameters
to
The source tensors to this tensor.
streamContext
The stream context to perform such operation.
-
Compute gradients from this tensor to the source tensor.
Declaration
Swift
public func backward<Group: DynamicGraph.AnyGroup>( to tensor: Group, streamContext: StreamContext? = nil )
Parameters
to
The source tensor to this tensor.
streamContext
The stream context to perform such operation.
-
Declaration
Swift
public func reshaped( format: TensorFormat, shape: TensorShape, offset: TensorShape? = nil, strides: TensorShape? = nil ) -> [Element]
-
Create new tensors pointing to the same memory region but with different sizes.
Declaration
Swift
public func reshaped( _ shapeFormat: TensorShapeFormat, offset: TensorShape? = nil, strides: TensorShape? = nil ) -> [Element]
Parameters
shapeFormat
New format and shape for the tensor.
offset
Whether offset on each shape.
strides
The strides on each shape.
Return Value
The new tensors with different format but the same memory content.
-
Declaration
Swift
public func reshaped( format: TensorFormat, shape: TensorShape, offset: TensorShape? = nil, strides: TensorShape? = nil ) -> [Element]
-
Create new tensors pointing to the same memory region but with different sizes.
Declaration
Swift
public func reshaped( _ shapeFormat: TensorShapeFormat, offset: TensorShape? = nil, strides: TensorShape? = nil ) -> [Element]
Parameters
shapeFormat
New format and shape for the tensor.
offset
Whether offset on each shape.
strides
The strides on each shape.
Return Value
The new tensors with different format but the same memory content.
-
Declaration
Swift
public func reshaped( format: TensorFormat, shape: TensorShape, offset: TensorShape? = nil, strides: TensorShape? = nil ) -> [Element]
-
Create new tensors pointing to the same memory region but with different sizes.
Declaration
Swift
public func reshaped( _ shapeFormat: TensorShapeFormat, offset: TensorShape? = nil, strides: TensorShape? = nil ) -> [Element]
Parameters
dimensionFormat
New format and shape for the tensor.
offset
Whether offset on each shape.
strides
The strides on each shape.
Return Value
The new tensors with different format but the same memory content.
-
Declaration
Swift
public func reshaped( format: TensorFormat, shape: TensorShape, offset: TensorShape? = nil, strides: TensorShape? = nil ) -> [Element]
-
Create new tensors pointing to the same memory region but with different sizes.
Declaration
Swift
public func reshaped( _ shapeFormat: TensorShapeFormat, offset: TensorShape? = nil, strides: TensorShape? = nil ) -> [Element]
Parameters
shapeFormat
New format and shape for the tensor.
offset
Whether offset on each shape.
strides
The strides on each shape.
Return Value
The new tensors with different format but the same memory content.
-
Declaration
Swift
public func reshaped( format: TensorFormat, shape: TensorShape, offset: TensorShape? = nil, strides: TensorShape? = nil ) -> [Element]
-
Create new tensors pointing to the same memory region but with different sizes.
Declaration
Swift
public func reshaped( _ shapeFormat: TensorShapeFormat, offset: TensorShape? = nil, strides: TensorShape? = nil ) -> [Element]
Return Value
The new tensors with different format but the same memory content.
-
Declaration
Swift
public func reshaped( format: TensorFormat, shape: TensorShape, offset: TensorShape? = nil, strides: TensorShape? = nil ) -> [Element]
-
Create new tensors pointing to the same memory region but with different sizes.
Declaration
Swift
public func reshaped( _ shapeFormat: TensorShapeFormat, offset: TensorShape? = nil, strides: TensorShape? = nil ) -> [Element]
Parameters
shapeFormat
New format and shape for the tensor.
offset
Whether offset on each shape.
strides
The strides on each shape.
Return Value
The new tensors with different format but the same memory content.