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.AnyTensorParameters
toThe source tensors to this tensor.
streamContextThe 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
toThe source tensor to this tensor.
streamContextThe 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.AnyGroupParameters
toThe source tensors to this tensor.
streamContextThe 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
toThe source tensor to this tensor.
streamContextThe 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
shapeFormatNew format and shape for the tensor.
offsetWhether offset on each shape.
stridesThe 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
shapeFormatNew format and shape for the tensor.
offsetWhether offset on each shape.
stridesThe 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
dimensionFormatNew format and shape for the tensor.
offsetWhether offset on each shape.
stridesThe 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
shapeFormatNew format and shape for the tensor.
offsetWhether offset on each shape.
stridesThe 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
shapeFormatNew format and shape for the tensor.
offsetWhether offset on each shape.
stridesThe strides on each shape.
Return Value
The new tensors with different format but the same memory content.
Collection Extension Reference