@frozen
public struct Tensor<Scalar> where Scalar : TensorFlowScalar
extension Tensor: Collatable
extension Tensor: CopyableToDevice
extension Tensor: AnyTensor
extension Tensor: ExpressibleByArrayLiteral
extension Tensor: CustomStringConvertible
extension Tensor: CustomPlaygroundDisplayConvertible
extension Tensor: CustomReflectable
extension Tensor: TensorProtocol
extension Tensor: TensorGroup
extension Tensor: ElementaryFunctions where Scalar: TensorFlowFloatingPoint
extension Tensor: VectorProtocol where Scalar: TensorFlowFloatingPoint
extension Tensor: Mergeable where Scalar: TensorFlowFloatingPoint
extension Tensor: Equatable where Scalar: Equatable
extension Tensor: Codable where Scalar: Codable
extension Tensor: AdditiveArithmetic where Scalar: Numeric
extension Tensor: PointwiseMultiplicative where Scalar: Numeric
extension Tensor: Differentiable & EuclideanDifferentiable where Scalar: TensorFlowFloatingPoint
extension Tensor: DifferentiableTensorProtocol
where Scalar: TensorFlowFloatingPoint
벡터와 행렬을 잠재적으로 더 높은 차원으로 일반화하는 요소의 다차원 배열입니다.
일반 파라미터 Scalar
(예 텐서의 스칼라 유형 설명 Int32
, Float
등).
기본이
TensorHandle
.메모
handle
사용자가 정의한 작전이 가능하도록 공개하지만, 일반적으로 사용되어서는 안된다.선언
public let handle: TensorHandle<Scalar>
선언
public init(handle: TensorHandle<Scalar>)
rank- 주어진 차원 압축이
R
여러 rank-로 텐서(R-1)
텐서. 압축이N
을 따라 치핑하여이 텐서에서 텐서axis
치수,N
이 텐서의 형상으로부터 유추된다. 예를 들면, 형상의 주어진 텐서[A, B, C, D]
:- 경우
axis == 0
다음i
반환 배열 번째 텐서 슬라이스 인self[i, :, :, :]
과 그 배열의 각 텐서 형상 것[B, C, D]
. (치수가 함께 풀었 것을 참고, 사라는 달리Tensor.split(numSplits:alongAxis)
, 또는Tensor.split(sizes:alongAxis)
). - 경우
axis == 1
다음i
반환 배열 번째 텐서 슬라이스 인value[:, i, :, :]
과 그 배열의 각 텐서 형상 것[A, C, D]
. - 등.
이 반대입니다
Tensor.init(stacking:alongAxis:)
.전제조건
axis
범위에 있어야[-rank, rank)
,rank
제공된 텐서의 계수이다.선언
@differentiable public func unstacked(alongAxis axis: Int = 0) -> [Tensor]
매개변수
axis
스택을 해제할 치수입니다. 음수 값은 둘러싸입니다.
반환 값
스택되지 않은 텐서를 포함하는 배열입니다.
- 경우
텐서를 여러 텐서로 나눕니다. 텐서는 차원을 따라 분할되는
axis
으로count
작은 텐서. 이것은 그 요구count
균등 분할의shape[axis]
.예를 들어:
// 'value' is a tensor with shape [5, 30] // Split 'value' into 3 tensors along dimension 1: let parts = value.split(count: 3, alongAxis: 1) parts[0] // has shape [5, 10] parts[1] // has shape [5, 10] parts[2] // has shape [5, 10]
전제조건
count
측정 기준의 크기는 분할해야axis
균등.전제조건
axis
범위에 있어야[-rank, rank)
,rank
제공된 텐서의 계수이다.선언
@differentiable public func split(count: Int, alongAxis axis: Int = 0) -> [Tensor]
매개변수
count
생성할 분할 수입니다.
axis
이 텐서를 분할할 차원입니다. 음수 값은 둘러싸입니다.
반환 값
텐서 부분을 포함하는 배열입니다.
텐서를 여러 텐서로 나눕니다. 텐서는로 분할
sizes.shape[0]
편. 형상의i
번째 부분은 치수가 함께 제외한이 텐서 동일한 형상 가진다axis
크기이고sizes[i]
.예를 들어:
// 'value' is a tensor with shape [5, 30] // Split 'value' into 3 tensors with sizes [4, 15, 11] along dimension 1: let parts = value.split(sizes: Tensor<Int32>([4, 15, 11]), alongAxis: 1) parts[0] // has shape [5, 4] parts[1] // has shape [5, 15] parts[2] // has shape [5, 11]
전제조건
의 값
sizes
치수의 크기까지 추가해야합니다axis
.전제조건
axis
범위에 있어야[-rank, rank)
,rank
제공된 텐서의 계수이다.선언
@differentiable(wrt: self) public func split(sizes: Tensor<Int32>, alongAxis axis: Int = 0) -> [Tensor]
매개변수
sizes
각 분할의 크기를 포함하는 1차원 텐서입니다.
axis
이 텐서를 분할할 차원입니다. 음수 값은 둘러싸입니다.
반환 값
텐서 부분을 포함하는 배열입니다.
선언
@differentiable(wrt: self) public func split(sizes: [Int], alongAxis axis: Int = 0) -> [Tensor]
이 텐서를 타일링하여 생성된 타일링된 텐서를 반환합니다.
이 생성자는이 텐서를 복제하여 새로운 텐서를 생성
multiples
시간을. 구축 된 텐서이다i
'번째 차원 갖는다self.shape[i] * multiples[i]
요소,이 텐서의 값이 복제되는multiples[i]
따라 회i
'번째 차원. 예를 들어, 타일링[abcd]
에 의해[2]
생산[abcdabcd]
.전제조건
형상의multiples
여야[tensor.rank]
.전제조건
모든 스칼라multiples
음이 아닌 수 있어야합니다.선언
@differentiable(wrt: self) public func tiled(multiples: [Int]) -> Tensor
이 텐서를 타일링하여 생성된 타일링된 텐서를 반환합니다.
이 생성자는이 텐서를 복제하여 새로운 텐서를 생성
multiples
시간을. 구축 된 텐서이다i
'번째 차원 갖는다self.shape[i] * multiples[i]
요소,이 텐서의 값이 복제되는multiples[i]
따라 회i
'번째 차원. 예를 들어, 타일링[abcd]
에 의해[2]
생산[abcdabcd]
.전제조건
형상의multiples
여야[tensor.rank]
.선언
@differentiable(wrt: self) public func tiled(multiples: Tensor<Int32>) -> Tensor
특정의 형상 모양 변경
Tensor
.전제조건
스칼라 개수는 새 모양과 일치합니다.선언
@differentiable(wrt: self) public func reshaped<T>(like other: Tensor<T>) -> Tensor where T : TensorFlowScalar
지정된 모양으로 모양을 변경합니다.
전제조건
스칼라 개수는 새 모양과 일치합니다.선언
@differentiable(wrt: self) public func reshaped(to newShape: TensorShape) -> Tensor
지정된로 모양 변경
Tensor
형태를 나타내는.전제조건
스칼라 개수는 새 모양과 일치합니다.선언
@differentiable(wrt: self) public func reshaped(toShape newShape: Tensor<Int32>) -> Tensor
1-D로 붕괴 텐서의 사본 돌아
Tensor
행 주요 순서.선언
@differentiable(wrt: self) public func flattened() -> Tensor
형상 발포 돌려
Tensor
지정된 형상 지수에 삽입 (1)의 치수와.선언
@differentiable(wrt: self) public func expandingShape(at axes: Int...) -> Tensor
형상 발포 돌려
Tensor
지정된 형상 지수에 삽입 (1)의 치수와.선언
@differentiable(wrt: self) public func expandingShape(at axes: [Int]) -> Tensor
순위-해제 반환
Tensor
하나의 선도적 인 차원과.선언
@differentiable(wrt: self) public func rankLifted() -> Tensor
텐서의 모양에서 크기 1의 지정된 차원을 제거합니다. 치수를 지정하지 않으면 크기 1의 모든 치수가 제거됩니다.
선언
@differentiable(wrt: self) public func squeezingShape(at axes: Int...) -> Tensor
텐서의 모양에서 크기 1의 지정된 차원을 제거합니다. 치수를 지정하지 않으면 크기 1의 모든 치수가 제거됩니다.
선언
@differentiable(wrt: self) public func squeezingShape(at axes: [Int]) -> Tensor
차원이 지정된 순서로 치환된 전치된 텐서를 반환합니다.
선언
@differentiable(wrt: self) public func transposed(permutation: Tensor<Int32>) -> Tensor
차원이 지정된 순서로 치환된 전치된 텐서를 반환합니다.
선언
@available(*, deprecated, renamed: "transposed(permutation:﹚") @differentiable(wrt: self) public func transposed(withPermutations permutations: Tensor<Int32>) -> Tensor
차원이 지정된 순서로 치환된 전치된 텐서를 반환합니다.
선언
@differentiable(wrt: self) public func transposed(permutation: [Int]) -> Tensor
차원이 지정된 순서로 치환된 전치된 텐서를 반환합니다.
선언
@available(*, deprecated, renamed: "transposed(permutation:﹚") @differentiable(wrt: self) public func transposed(withPermutations permutations: [Int]) -> Tensor
차원이 지정된 순서로 치환된 전치된 텐서를 반환합니다.
선언
@differentiable(wrt: self) public func transposed(permutation: Int...) -> Tensor
차원이 지정된 순서로 치환된 전치된 텐서를 반환합니다.
선언
@available(*, deprecated, renamed: "transposed(permutation:﹚") @differentiable(wrt: self) public func transposed(withPermutations permutations: Int...) -> Tensor
차원이 역순으로 치환된 전치된 텐서를 반환합니다.
선언
@differentiable(wrt: self) public func transposed() -> Tensor
지정된 차원이 반전된 텐서를 반환합니다.
전제조건
각 값axes
범위에 있어야-rank..<rank
.전제조건
에는 중복이 없어야합니다axes
.선언
@differentiable(wrt: self) public func reversed(inAxes axes: Tensor<Int32>) -> Tensor
지정된 차원이 반전된 텐서를 반환합니다.
전제조건
각 값axes
범위에 있어야-rank..<rank
.전제조건
에는 중복이 없어야합니다axes
.선언
@differentiable(wrt: self) public func reversed(inAxes axes: [Int]) -> Tensor
지정된 차원이 반전된 텐서를 반환합니다.
전제조건
각 값axes
범위에 있어야-rank..<rank
.전제조건
에는 중복이 없어야합니다axes
.선언
@differentiable(wrt: self) public func reversed(inAxes axes: Int...) -> Tensor
지정된 축을 따라 연결된 텐서를 반환합니다.
전제조건
텐서는 지정된 축을 제외하고 동일한 차원을 가져야 합니다.전제조건
축이 범위에 있어야-rank..<rank
.선언
@differentiable public func concatenated(with other: Tensor, alongAxis axis: Int = 0) -> Tensor
연결 연산자.
메모
++
스위프트에 존재하지 않는 사용자 정의 연산자이지만, 하스켈 / 스칼라 않습니다. 그것의 추가는 사소한 언어 변경이 아니며 논쟁의 여지가 있습니다. 존재 /의 이름++
나중에 API의 설계 단계에서 논의 될 것이다.선언
@differentiable public static func ++ (lhs: Tensor, rhs: Tensor) -> Tensor
입력에서의 슬라이스를 수집하여 텐서를 돌려
indices
따라axis
치수0-D (스칼라) 용
indices
:result[p_0, ..., p_{axis-1}, p_{axis + 1}, ..., p_{N-1}] = self[p_0, ..., p_{axis-1}, indices, p_{axis + 1}, ..., p_{N-1}]
1-D (벡터) 용
indices
:result[p_0, ..., p_{axis-1}, i, p_{axis + 1}, ..., p_{N-1}] = self[p_0, ..., p_{axis-1}, indices[i], p_{axis + 1}, ..., p_{N-1}]
일반적인 경우 다음과 같은 결과 텐서를 생성합니다.
result[p_0, ..., p_{axis-1}, i_{batch\_dims}, ..., i_{M-1}, p_{axis + 1}, ..., p_{N-1}] = self[p_0, ..., p_{axis-1}, indices[i_0, ..., i_{M-1}], p_{axis + 1}, ..., p_{N-1}]
여기서
N = self.rank
및M = indices.rank
.얻어진 텐서의 형상이다
self.shape[..<axis] + indices.shape + self.shape[(axis + 1)...]
.메모
CPU에서 범위를 벗어난 인덱스가 발견되면 오류가 발생합니다. GPU에서 범위를 벗어난 인덱스가 발견되면 해당 출력 값에 0이 저장됩니다.
전제조건
axis
범위에 있어야[-rank, rank)
.선언
@differentiable(wrt: self) public func gathering<Index: TensorFlowIndex>( atIndices indices: Tensor<Index>, alongAxis axis: Int = 0 ) -> Tensor
매개변수
indices
수집할 인덱스를 포함합니다.
axis
수집할 치수입니다. 음수 값은 둘러싸입니다.
반환 값
수집된 텐서.
에 반환이 텐서 슬라이스
indices
따라axis
치수, 제 무시하면서batchDimensionCount
치수를 그 배치 크기에 대응한다. 수집은 배치가 아닌 첫 번째 차원을 따라 수행됩니다.유사한 기능을 수행하는
gathering
결과 텐서 형상 지금 것을 제외하고,shape[..<axis] + indices.shape[batchDimensionCount...] + shape[(axis + 1)...]
.전제조건
axis
범위에 있어야-rank..<rank
도보다 큰거나 같은 동안batchDimensionCount
.전제조건
batchDimensionCount
보다 작아야합니다indices.rank
.선언
@differentiable(wrt: self) public func batchGathering<Index: TensorFlowIndex>( atIndices indices: Tensor<Index>, alongAxis axis: Int = 1, batchDimensionCount: Int = 1 ) -> Tensor
매개변수
indices
수집할 인덱스를 포함합니다.
axis
수집할 치수입니다. 음수 값은 둘러싸입니다.
batchDimensionCount
무시할 선행 배치 차원의 수입니다.
반환 값
수집된 텐서.
입력에 제공된 부울 마스크를 적용한 후 값을 수집하여 텐서를 반환합니다.
예를 들어:
// 1-D example // tensor is [0, 1, 2, 3] // mask is [true, false, true, false] tensor.gathering(where: mask) // is [0, 2] // 2-D example // tensor is [[1, 2], [3, 4], [5, 6]] // mask is [true, false, true] tensor.gathering(where: mask) // is [[1, 2], [5, 6]]
일반적으로
0 < mask.rank = K <= tensor.rank
하고,mask
의 형상은 상기 제 K의 크기와 일치해야tensor
의 형상 '. 우리는 다음과 같습니다tensor.gathering(where: mask)[i, j1, ..., jd] = tensor[i1, ..., iK, j1, ..., jd]
여기서[i1, ..., iK]
은 ISi
일true
의 입력mask
(행 우선 순서).axis
함께 사용할 수있는mask
에서 마스크 할 수있는 축을 나타냅니다. 이 경우,axis + mask.rank <= tensor.rank
상기mask
's shape must match the first
축 + mask.rankdimensions of the
tensor`의 형상.전제조건
mask
: 스칼라 수 없습니다mask.rank != 0
.선언
@differentiable(wrt: self) public func gathering(where mask: Tensor<Bool>, alongAxis axis: Int = 0) -> Tensor
매개변수
mask
KD 부울 텐서,
K <= self.rank
.axis
축에 나타내는 정수 텐서 0-D
self
에서 마스크하기 위해,K + axis <= self.rank
.반환 값
(self.rank - K + 1)
에 대응이 텐서 항목 채워 차원 텐서true
의 값mask
.이 텐서에서 0이 아닌/참 값의 위치를 반환합니다.
좌표는 첫 번째 차원(행)이 0이 아닌 요소의 수를 나타내고 두 번째 차원(열)이 0이 아닌 요소의 좌표를 나타내는 2차원 텐서로 반환됩니다. 출력 텐서의 모양은 이 텐서에 얼마나 많은 실제 값이 있는지에 따라 달라질 수 있습니다. 인덱스는 행 우선 순위로 출력됩니다.
예를 들어:
// 'input' is [[true, false], [true, false]] // 'input' has 2 true values and so the output has 2 rows. // 'input' has rank of 2, and so the second dimension of the output has size 2. input.nonZeroIndices() // is [[0, 0], [1, 0]] // 'input' is [[[ true, false], [ true, false]], // [[false, true], [false, true]], // [[false, false], [false, true]]] // 'input' has 5 true values and so the output has 5 rows. // 'input' has rank 3, and so the second dimension of the output has size 3. input.nonZeroIndices() // is [[0, 0, 0], // [0, 1, 0], // [1, 0, 1], // [1, 1, 1], // [2, 1, 1]]
선언
public func nonZeroIndices() -> Tensor<Int64>
반환 값
모양 텐서
(num_true, rank(condition))
.선언
@differentiable(wrt: self) public func broadcasted(toShape shape: Tensor<Int32>) -> Tensor
선언
@differentiable(wrt: self) public func broadcasted(to shape: TensorShape) -> Tensor
지정된 같은 모양 방송
Tensor
.전제조건
지정된 모양은 방송에 적합해야 합니다.선언
@differentiable(wrt: self) public func broadcasted<OtherScalar>(like other: Tensor<OtherScalar>) -> Tensor where OtherScalar : TensorFlowScalar
선언
public static func .= (lhs: inout Tensor, rhs: Tensor)
각 차원의 하한 및 상한으로 정의된 텐서에서 슬라이스를 추출합니다.
선언
@differentiable(wrt: self) public func slice(lowerBounds: [Int], upperBounds: [Int]) -> Tensor
매개변수
lowerBounds
각 차원의 하한입니다.
upperBounds
각 차원의 상한입니다.
선언
@differentiable(wrt: self) public func slice(lowerBounds: Tensor<Int32>, sizes: Tensor<Int32>) -> Tensor
선언
@differentiable(wrt: self) public func slice(lowerBounds: [Int], sizes: [Int]) -> Tensor
선언
@differentiable(wrt: self) public subscript(ranges: TensorRangeExpression...) -> Tensor { get set }
각 소자 검사
axes
축선 나타내고self
, 그렇지 않으면 진단을 가진 프로그램을 정지한다.선언
func ensureValid( axes: Tensor<Int32>, function: StaticString = #function, file: StaticString = #file, line: UInt = #line )
각 소자 검사
axes
축선 나타내고self
, 그렇지 않으면 진단을 가진 프로그램을 정지한다.선언
func ensureValid( axes: [Int], function: StaticString = #function, file: StaticString = #file, line: UInt = #line )
검사는
k
축선 나타내고self
, 그렇지 않으면 진단을 가진 프로그램을 정지한다.선언
func ensureValid( axis k: Int, function: StaticString = #function, file: StaticString = #file, line: UInt = #line )
선언
public init<BatchSamples: Collection>(collating samples: BatchSamples) where BatchSamples.Element == Self
지정된 모양과 단일 반복 스칼라 값으로 텐서를 만듭니다.
선언
@available(*, deprecated, renamed: "init(repeating:shape:﹚") public init(shape: TensorShape, repeating repeatedValue: Scalar)
매개변수
shape
텐서의 차원입니다.
repeatedValue
반복할 스칼라 값입니다.
지정된 모양과 단일 반복 스칼라 값으로 텐서를 만듭니다.
선언
@differentiable public init( repeating repeatedValue: Scalar, shape: TensorShape, on device: Device = .default )
매개변수
repeatedValue
반복할 스칼라 값입니다.
shape
텐서의 차원입니다.
모든 차원이 1인 지정된 순위에 지정된 스칼라를 브로드캐스트하여 텐서를 만듭니다.
선언
public init(broadcasting scalar: Scalar, rank: Int, on device: Device = .default)
텐서의 배열(스칼라일 수 있음)에서 텐서를 만듭니다.
선언
@differentiable public init(_ elements: [Tensor])
스택의
tensors
따라,axis
현재 텐서 및 각 텐서보다 높은 순위 하나의 새로운 텐서에 차원tensors
.감안할
tensors
모든 형태가[A, B, C]
, 및tensors.count = N
다음을 :- 만약
axis == 0
그 결과 텐서 형상 것[N, A, B, C]
. - 만약
axis == 1
그 결과 텐서 형상 것[A, N, B, C]
. - 등.
예를 들어:
// 'x' is [1, 4] // 'y' is [2, 5] // 'z' is [3, 6] Tensor(stacking: [x, y, z]) // is [[1, 4], [2, 5], [3, 6]] Tensor(stacking: [x, y, z], alongAxis: 1) // is [[1, 2, 3], [4, 5, 6]]
이 반대입니다
Tensor.unstacked(alongAxis:)
.전제조건
모든 텐서는 모양이 같아야 합니다.
전제조건
axis
범위에 있어야[-rank, rank)
,rank
제공된 텐서의 계수이다.선언
@differentiable public init(stacking tensors: [Tensor], alongAxis axis: Int = 0)
매개변수
tensors
쌓을 텐서.
axis
쌓을 치수입니다. 음수 값은 둘러싸입니다.
반환 값
스택 텐서.
- 만약
연결합니다
tensors
함께axis
차원을.주어진
tensors[i].shape = [D0, D1, ... Daxis(i), ...Dn]
다음 연접 결과가 갖는 형상[D0, D1, ... Raxis, ...Dn]
, 여기서Raxis = sum(Daxis(i))
. 즉, 입력 텐서의 데이터는 함께 결합되어axis
치수.예를 들어:
// t1 is [[1, 2, 3], [4, 5, 6]] // t2 is [[7, 8, 9], [10, 11, 12]] Tensor(concatenating: [t1, t2]) // is [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]] Tensor(concatenating: [t1, t2], alongAxis: 1) // is [[1, 2, 3, 7, 8, 9], [4, 5, 6, 10, 11, 12]] // t3 has shape [2, 3] // t4 has shape [2, 3] Tensor(concatenating: [t3, t4]) // has shape [4, 3] Tensor(concatenating: [t3, t4], alongAxis: 1) // has shape [2, 6]
메모
사용을 고려 새로운 축을 따라 합치하는 경우
Tensor.init(stacking:alongAxis:)
.전제조건
모든 텐서는 동일한 순위를 가져야하며 제외한 모든 차원
axis
동일해야합니다.전제조건
axis
범위에 있어야[-rank, rank)
,rank
제공된 텐서의 계수이다.선언
@differentiable public init(concatenating tensors: [Tensor], alongAxis axis: Int = 0)
매개변수
tensors
연결할 텐서입니다.
axis
연결할 차원입니다. 음수 값은 둘러싸입니다.
반환 값
연결된 텐서입니다.
이 텐서의 요소 대체
other
차선에서mask
입니다true
.전제조건
self
와other
반드시 같은 모양을 가지고있다. 경우self
와other
스칼라, 다음mask
도 스칼라해야합니다. 경우self
와other
것보다 더 큰 랭크가 동일하거나1
후,mask
여야 동일한 형상이self
또는 D-1 일Tensor
되도록mask.scalarCount == self.shape[0]
.선언
@differentiable(wrt: (self, other) ) public func replacing(with other: Tensor, where mask: Tensor<Bool>) -> Tensor
물리적 스칼라 유형이 감소된 정밀도인 경우 true를 반환합니다.
현재 감소 정밀 물리적 스칼라 유형 만 포함
BFloat16
.선언
public var isReducedPrecision: Bool { get }
주어진 텐서와 동일한 장치 및 정밀도로 스칼라를 텐서로 승격합니다.
선언
@differentiable public init(_ value: Scalar, deviceAndPrecisionLike tensor: Tensor)
반환의 사본
self
로 변환BFloat16
물리적 스칼라 유형입니다.선언
public var toReducedPrecision: `Self` { get }
반환의 사본
self
로 변환Scalar
물리적 스칼라 유형입니다.선언
public var toFullPrecision: `Self` { get }
의 차원 수
Tensor
.선언
public var rank: Int { get }
의 모양
Tensor
.선언
public var shape: TensorShape { get }
에서 스칼라의 수
Tensor
.선언
public var scalarCount: Int { get }
A와 표현되는 텐서의 랭크,
Tensor<Int32>
.선언
public var rankTensor: Tensor<Int32> { get }
A와 표현되는 텐서의 치수
Tensor<Int32>
.선언
public var shapeTensor: Tensor<Int32> { get }
A와 표현되는 텐서의 스칼라의 수
Tensor<Int32>
.선언
public var scalarCountTensor: Tensor<Int32> { get }
반환
true
경우rank
0과 같다false
그렇지.선언
public var isScalar: Bool { get }
반환 단일 스칼라 요소를하면
rank
0과 같다nil
그렇지.선언
public var scalar: Scalar? { get }
스칼라로 모양을 변경합니다.
전제조건
텐서는 정확히 하나의 스칼라를 갖습니다.선언
@differentiable public func scalarized() -> Scalar
선언
public var array: ShapedArray<Scalar> { get }
선언
@differentiable public var scalars: [Scalar] { get }
스칼라 값에서 0차원 텐서를 만듭니다.
선언
@differentiable public init(_ value: Scalar, on device: Device = .default)
스칼라에서 1D 텐서를 생성합니다.
선언
@differentiable public init(_ scalars: [Scalar], on device: Device = .default)
스칼라에서 1D 텐서를 생성합니다.
선언
public init<C: Collection>( _ vector: C, on device: Device = .default ) where C.Element == Scalar
행 우선 순서로 지정된 모양과 연속 스칼라를 사용하여 텐서를 만듭니다.
전제조건
모양 차원의 곱은 스칼라 수와 같아야 합니다.선언
@differentiable public init(shape: TensorShape, scalars: [Scalar], on device: Device = .default)
매개변수
shape
텐서의 모양.
scalars
텐서의 스칼라 내용입니다.
행 우선 순서로 지정된 모양과 연속 스칼라를 사용하여 텐서를 만듭니다.
전제조건
모양 차원의 곱은 스칼라 수와 같아야 합니다.선언
public init( shape: TensorShape, scalars: UnsafeBufferPointer<Scalar>, on device: Device = .default )
매개변수
shape
텐서의 모양.
scalars
텐서의 스칼라 내용입니다.
행 우선 순서로 지정된 모양과 연속 스칼라를 사용하여 텐서를 만듭니다.
전제조건
모양 차원의 곱은 스칼라 수와 같아야 합니다.행 우선 순서로 지정된 모양과 연속 스칼라를 사용하여 텐서를 만듭니다.
전제조건
모양 차원의 곱은 스칼라 수와 같아야 합니다.선언
public init<C: Collection>( shape: TensorShape, scalars: C, on device: Device = .default ) where C.Element == Scalar
매개변수
shape
텐서의 모양.
scalars
텐서의 스칼라 내용입니다.
배열 리터럴의 요소 유형입니다.
선언
public typealias ArrayLiteralElement = _TensorElementLiteral<Scalar>
주어진 요소로 초기화된 텐서를 생성합니다.
선언
public init(arrayLiteral elements: _TensorElementLiteral<Scalar>...)
텐서의 텍스트 표현입니다.
메모
사용fullDescription
모든 스칼라을 보여주는 비 꽤 인쇄 설명.선언
public var description: String { get }
텐서의 텍스트 표현입니다. 경우 요약 된 설명을 리턴
summarize
사실과 요소 수는 두 배를 초과edgeElementCount
.선언
public func description( lineWidth: Int = 80, edgeElementCount: Int = 3, summarizing: Bool = false ) -> String
매개변수
lineWidth
인쇄를 위한 최대 선 너비입니다. 줄당 인쇄할 스칼라 수를 결정하는 데 사용됩니다.
edgeElementCount
요소의 최대 개수 (타원 통해 전후 요약을 인쇄
...
).summarizing
true의 경우 요소의 수를 두 번 초과하는 경우, 설명을 요약
edgeElementCount
.모든 스칼라를 보여주는 텐서의 전체, 예쁘게 인쇄되지 않은 텍스트 표현입니다.
선언
public var fullDescription: String { get }
선언
public var playgroundDescription: Any { get }
선언
public var customMirror: Mirror { get }
이 텐서를 설명하는 주석입니다.
선언
public var annotations: String { get }
주석의 별칭입니다.
선언
public var summary: String { get }
선언
public init(_owning tensorHandles: UnsafePointer<CTensorHandle>?)
선언
public init<C: RandomAccessCollection>( _handles: C ) where C.Element: _AnyTensorHandle
선언
public init(_ array: ShapedArray<Scalar>, on device: Device = .default)
선언
init(_xla: XLATensor)
선언
init(_xlaHandle: UnsafeMutablePointer<OpaqueXLATensor>)
선언
var xlaHandle: UnsafeMutablePointer<OpaqueXLATensor> { get }
선언
var xlaTensor: XLATensor { get }
선언
@differentiable(wrt: self) public func unbroadcasted(toShape otherShape: Tensor<Int32>) -> Tensor
선언
@differentiable(wrt: self) public func unbroadcasted<OtherScalar>(like other: Tensor<OtherScalar>) -> Tensor where OtherScalar : TensorFlowScalar
선언
@differentiable(wrt: self) public func unbroadcasted(to shape: TensorShape) -> Tensor
텐서가 채워지는 방법을 지시하는 모드입니다.
선언
public enum PaddingMode
지정된 패딩 크기에 따라 상수로 채워진 텐서를 반환합니다.
선언
@differentiable(wrt: self) public func padded(forSizes sizes: [(before: Int, after: Int)], with value: Scalar = 0) -> Tensor
지정된 패딩 크기와 모드에 따라 패딩된 텐서를 반환합니다.
선언
@differentiable(wrt: self) public func padded(forSizes sizes: [(before: Int, after: Int)], mode: PaddingMode) -> Tensor
반환 계산함으로써 부울 스칼라의 텐서
lhs < rhs
요소 현명한.선언
public static func .< (lhs: Tensor, rhs: Tensor) -> Tensor<Bool>
반환 계산함으로써 부울 스칼라 텐서
lhs <= rhs
소자 현명.선언
public static func .<= (lhs: Tensor, rhs: Tensor) -> Tensor<Bool>
반환 계산함으로써 부울 스칼라의 텐서
lhs > rhs
요소 현명한.선언
public static func .> (lhs: Tensor, rhs: Tensor) -> Tensor<Bool>
계산하여 반환 부울 스칼라 텐서
lhs >= rhs
소자 현명.선언
public static func .>= (lhs: Tensor, rhs: Tensor) -> Tensor<Bool>
반환 계산함으로써 부울 스칼라의 텐서
lhs < rhs
요소 현명한.메모
.<
지지체 방송.선언
public static func .< (lhs: Scalar, rhs: Tensor) -> Tensor<Bool>
반환 계산함으로써 부울 스칼라 텐서
lhs <= rhs
소자 현명.메모
.<=
지지체 방송.선언
public static func .<= (lhs: Scalar, rhs: Tensor) -> Tensor<Bool>
반환 계산함으로써 부울 스칼라의 텐서
lhs > rhs
요소 현명한.메모
.>
방송 지원합니다.선언
public static func .> (lhs: Scalar, rhs: Tensor) -> Tensor<Bool>
계산하여 반환 부울 스칼라 텐서
lhs >= rhs
소자 현명.메모
.>=
방송 지지체.선언
public static func .>= (lhs: Scalar, rhs: Tensor) -> Tensor<Bool>
반환 계산함으로써 부울 스칼라의 텐서
lhs < rhs
요소 현명한.메모
.<
지지체 방송.선언
public static func .< (lhs: Tensor, rhs: Scalar) -> Tensor<Bool>
반환 계산함으로써 부울 스칼라 텐서
lhs <= rhs
소자 현명.메모
.<=
지지체 방송.선언
public static func .<= (lhs: Tensor, rhs: Scalar) -> Tensor<Bool>
반환 계산함으로써 부울 스칼라의 텐서
lhs > rhs
요소 현명한.메모
.>
방송 지원합니다.선언
public static func .> (lhs: Tensor, rhs: Scalar) -> Tensor<Bool>
계산하여 반환 부울 스칼라 텐서
lhs >= rhs
소자 현명.메모
.>=
방송 지지체.선언
public static func .>= (lhs: Tensor, rhs: Scalar) -> Tensor<Bool>
반환 계산함으로써 부울 스칼라의 텐서
lhs == rhs
요소 현명한.메모
.==
지지체 방송.선언
public static func .== (lhs: Tensor, rhs: Tensor) -> Tensor<Bool>
반환 계산함으로써 부울 스칼라의 텐서
lhs != rhs
요소 현명한.메모
.!=
지원은 방송.선언
public static func .!= (lhs: Tensor, rhs: Tensor) -> Tensor<Bool>
반환 계산함으로써 부울 스칼라의 텐서
lhs == rhs
요소 현명한.메모
.==
지지체 방송.선언
public static func .== (lhs: Scalar, rhs: Tensor) -> Tensor<Bool>
반환 계산함으로써 부울 스칼라의 텐서
lhs != rhs
요소 현명한.메모
.!=
지원은 방송.선언
public static func .!= (lhs: Scalar, rhs: Tensor) -> Tensor<Bool>
반환 계산함으로써 부울 스칼라의 텐서
lhs == rhs
요소 현명한.메모
.==
지지체 방송.선언
public static func .== (lhs: Tensor, rhs: Scalar) -> Tensor<Bool>
반환 계산함으로써 부울 스칼라의 텐서
lhs != rhs
요소 현명한.메모
.!=
지원은 방송.선언
public static func .!= (lhs: Tensor, rhs: Scalar) -> Tensor<Bool>
반환 요소 여부를 나타내는 부울 값 텐서
self
의 것과 대략 동일한other
.전제조건
self
와other
필수는 같은 모양의 수.선언
public func elementsAlmostEqual( _ other: Tensor, tolerance: Scalar = Scalar.ulpOfOne.squareRoot() ) -> Tensor<Bool>
반환
true
모든 요소 경우self
의 것과 거의 동일하다other
.전제조건
self
와other
필수는 같은 모양의 수.선언
public func isAlmostEqual( to other: Tensor, tolerance: Scalar = Scalar.ulpOfOne.squareRoot() ) -> Bool
이 텐서에 대해 교차 복제본 합계를 실행합니다. 합계에 참여하는 다른 각 장치에서 동일한 교차 복제본 합계가 발생해야 합니다.
선언
public mutating mutating func crossReplicaSum(_ scale: Double)
A로부터 요소 - 현명한 타입 변환을 수행
Bool
텐서를.선언
public init(_ other: Tensor<Bool>)
서로 요소 현명한 변환을 수행
Tensor
.선언
@differentiable public init<OtherScalar>(_ other: Tensor<OtherScalar>) where OtherScalar : Numeric, OtherScalar : TensorFlowScalar
선언
@derivative init(_: <<error type>>)
선언
@derivative init(stacking: alongAxis)
선언
@derivative init(concatenating: alongAxis)
모든 스칼라가 0으로 설정된 텐서를 생성합니다.
선언
public init(zeros shape: TensorShape, on device: Device = .default)
매개변수
shape
텐서의 모양.
모든 스칼라가 1로 설정된 텐서를 생성합니다.
선언
public init(ones shape: TensorShape, on device: Device = .default)
매개변수
shape
텐서의 모양.
제공된 텐서와 모양 및 유형이 동일한 모든 스칼라가 0으로 설정된 텐서를 생성합니다.
선언
public init(zerosLike other: Tensor)
매개변수
other
사용할 모양과 데이터 유형의 텐서입니다.
모든 스칼라가 제공된 텐서와 모양 및 유형이 동일한 것으로 설정된 텐서를 생성합니다.
선언
public init(onesLike other: Tensor)
매개변수
other
사용할 모양과 데이터 유형의 텐서입니다.
시작 값에서 끝 값까지의 시퀀스를 나타내는 1차원 텐서를 생성하고 지정된 양만큼 스테핑합니다.
선언
public init( rangeFrom start: Scalar, to end: Scalar, stride: Scalar, on device: Device = .default )
매개변수
start
시퀀스에 사용할 시작 값입니다. 순서가 어떤 값을 포함 할 경우, 첫 번째입니다
start
.end
시퀀스를 제한하는 끝 값입니다.
end
얻어진 시퀀스의 요소 결코.stride
각 반복에서 단계별로 수행할 양입니다.
stride
양수 여야합니다.시작 값에서 끝 값까지의 시퀀스를 나타내는 1차원 텐서를 생성하고 지정된 양만큼 스테핑합니다.
선언
public init(rangeFrom start: Tensor<Scalar>, to end: Tensor<Scalar>, stride: Tensor<Scalar>)
매개변수
start
시퀀스에 사용할 시작 값입니다. 순서가 어떤 값을 포함 할 경우, 첫 번째입니다
start
.end
시퀀스를 제한하는 끝 값입니다.
end
얻어진 시퀀스의 요소 결코.stride
각 반복에서 단계별로 수행할 양입니다.
stride
양수 여야합니다.주어진 인덱스에서 원-핫 텐서를 생성합니다. 로 표시되는 위치
indices
값을 취onValue
(1
모든 다른 위치 값을 취할 때, 디폴트)를offValue
(0
디폴트 참조). 입력하면indices
순위 인n
, 새 순위는 텐서 것이다n+1
. 새로운 축 차원에서 생성되는axis
(기본적으로, 새로운 축 단부에 부가된다).경우
indices
스칼라이며, 새로운 텐서의 모양은 길이의 벡터가 될 것이다depth
.경우
indices
길이의 벡터이다features
출력 형태가 될 것이다 기능 X 깊이 경우 축 == -1 기능 깊이 X 축 == 0하다면경우
indices
형상의 매트릭스 (배치)이다[batch, features]
출력 형상됩니다 배치 X는 X 깊이를 갖추고있는 경우 축 == -1 일괄 X 깊이 X 기능 축 == 1 깊이 X 배치 X 경우 고급 , 축 == 0인 경우선언
public init( oneHotAtIndices indices: Tensor<Int32>, depth: Int, onValue: Scalar = 1, offValue: Scalar = 0, axis: Int = -1 )
매개변수
indices
Tensor
지표.depth
하나의 핫 차원의 깊이를 정의하는 스칼라.
onValue
위치의 값을 정의하는 스칼라 일부 인덱스에 의해 참조
indices
.offValue
어떤 인덱스에 의해 참조되지 않은 위치에서의 값을 정의하는 스칼라
indices
.axis
채울 축입니다. 기본값은
-1
, 새로운 가장 안쪽 축.
지정된 수의 값을 생성하기 위해 균등한 간격으로 시작 값에서 끝 값까지의 시퀀스를 나타내는 1차원 텐서를 만듭니다.
선언
public init( linearSpaceFrom start: Scalar, to end: Scalar, count: Int, on device: Device = .default )
매개변수
start
시퀀스에 사용할 시작 값입니다. 순서가 어떤 값을 포함 할 경우, 첫 번째입니다
start
.end
시퀀스를 제한하는 끝 값입니다.
end
얻어진 시퀀스의 마지막 한 요소이다.count
결과 시퀀스의 값 수입니다.
count
양수 여야합니다.지정된 수의 값을 생성하기 위해 균등한 간격으로 시작 값에서 끝 값까지의 시퀀스를 나타내는 1차원 텐서를 만듭니다.
전제조건
start
,to
, 그리고count
단일 스칼라 값을 포함 텐서해야합니다.선언
public init(linearSpaceFrom start: Tensor<Scalar>, to end: Tensor<Scalar>, count: Tensor<Int32>)
매개변수
start
시퀀스에 사용할 시작 값입니다. 순서가 어떤 값을 포함 할 경우, 첫 번째입니다
start
.end
시퀀스를 제한하는 끝 값입니다.
end
얻어진 시퀀스의 마지막 한 요소이다.count
결과 시퀀스의 값 수입니다.
count
양수 여야합니다.
임의로 간의 균일 한 분포로부터 스칼라 값을 샘플링 지정된 형상 텐서를 작성
lowerBound
및upperBound
.선언
public init( randomUniform shape: TensorShape, lowerBound: Tensor<Scalar>? = nil, upperBound: Tensor<Scalar>? = nil, seed: TensorFlowSeed = Context.local.randomSeed, on device: Device = .default )
매개변수
shape
텐서의 차원입니다.
lowerBound
분포의 하한입니다.
upperBound
분포의 상한입니다.
seed
시드 값입니다.
임의로 간의 균일 한 분포로부터 스칼라 값을 샘플링 지정된 형상 텐서를 작성
lowerBound
및upperBound
.선언
public init( randomUniform shape: TensorShape, lowerBound: Tensor<Scalar>? = nil, upperBound: Tensor<Scalar>? = nil, seed: TensorFlowSeed = Context.local.randomSeed, on device: Device = .default )
매개변수
shape
텐서의 차원입니다.
lowerBound
분포의 하한입니다.
upperBound
분포의 상한입니다.
seed
시드 값입니다.
정규 분포에서 무작위로 스칼라 값을 샘플링하여 지정된 모양으로 텐서를 만듭니다.
선언
public init( randomNormal shape: TensorShape, mean: Tensor<Scalar>? = nil, standardDeviation: Tensor<Scalar>? = nil, seed: TensorFlowSeed = Context.local.randomSeed, on device: Device = .default )
매개변수
shape
텐서의 차원입니다.
mean
분포의 평균입니다.
standardDeviation
분포의 표준 편차입니다.
seed
시드 값입니다.
잘린 정규 분포에서 무작위로 스칼라 값을 샘플링하여 지정된 모양으로 텐서를 만듭니다.
선언
public init( randomTruncatedNormal shape: TensorShape, mean: Tensor<Scalar>? = nil, standardDeviation: Tensor<Scalar>? = nil, seed: TensorFlowSeed = Context.local.randomSeed, on device: Device = .default )
매개변수
shape
텐서의 차원입니다.
mean
분포의 평균입니다.
standardDeviation
분포의 표준 편차입니다.
seed
시드 값입니다.
범주형 분포에서 샘플을 가져와 텐서를 만듭니다.
선언
public init<T: TensorFlowFloatingPoint>( randomCategorialLogits: Tensor<T>, sampleCount: Int32, seed: TensorFlowSeed = Context.local.randomSeed )
매개변수
randomCategorialLogits
형상의 2-D 텐서
[batchSize, classCount]
. 각 슬라이스는[i, :]
모든 클래스 표준화 로그 확률을 나타낸다.sampleCount
0-D. 각 행 조각에 대해 그릴 독립 샘플 수입니다.
seed
시드 값입니다.
반환 값
형상의 2-D 텐서
[batchSize, sampleCount]
. 각 슬라이스는[i, :]
범위 연신 클래스 라벨 포함[0, classCount)
.
Glorot(Xavier) 균일 초기화를 수행하여 지정된 모양의 텐서를 생성합니다.
그것은 간의 균일 한 분포로부터 임의의 샘플을 끌어
-limit
및limit
기본 난수 발생기에 의해 생성되는limit
이다sqrt(6 / (fanIn + fanOut))
및fanIn
/fanOut
받아들이는 승산 기능 입력과 출력의 개수를 나타낸다 필드 크기.선언
public init( glorotUniform shape: TensorShape, seed: TensorFlowSeed = Context.local.randomSeed, on device: Device = .default )
매개변수
shape
텐서의 차원입니다.
seed
시드 값입니다.
Glorot(Xavier) 일반 초기화를 수행하여 지정된 모양으로 텐서를 생성합니다.
이는 절두 정규 분포로부터 무작위 샘플 중심 무
0
표준 편차와sqrt(2 / (fanIn + fanOut))
기본 랜덤 넘버 생성기에 의해 생성fanIn
/fanOut
입력과 출력의 개수를 나타낸다는 수용 필드 승산 기능 크기.선언
public init( glorotNormal shape: TensorShape, seed: TensorFlowSeed = Context.local.randomSeed, on device: Device = .default )
매개변수
shape
텐서의 차원입니다.
seed
시드 값입니다.
He(Kaiming) 균일 초기화를 수행하여 지정된 모양으로 텐서를 생성합니다.
그것은 간의 균일 한 분포로부터 임의의 샘플을 끌어
-limit
및limit
기본 난수 발생기에 의해 생성되는limit
이다sqrt(6 / fanIn)
및fanIn
입력의 수가 수용 필드의 크기를 곱한 기능을 나타낸다.선언
public init( heUniform shape: TensorShape, seed: TensorFlowSeed = Context.local.randomSeed, on device: Device = .default )
매개변수
shape
텐서의 차원입니다.
seed
시드 값입니다.
He(Kaiming) 일반 초기화를 수행하여 지정된 모양으로 텐서를 생성합니다.
이는 절두 정규 분포로부터 무작위 샘플 중심 무
0
표준 편차와sqrt(2 / fanIn))
기본 랜덤 넘버 생성기에 의해 생성fanIn
입력의 수가 수용 필드의 크기를 곱한 기능을 나타낸다.선언
public init( heNormal shape: TensorShape, seed: TensorFlowSeed = Context.local.randomSeed, on device: Device = .default )
매개변수
shape
텐서의 차원입니다.
seed
시드 값입니다.
LeCun 균일 초기화를 수행하여 지정된 모양으로 텐서를 생성합니다.
그것은 간의 균일 한 분포로부터 임의의 샘플을 끌어
-limit
및limit
기본 난수 발생기에 의해 생성되는limit
이다sqrt(3 / fanIn)
및fanIn
입력의 수가 수용 필드의 크기를 곱한 기능을 나타낸다.참조 : "효율적인 BackProp"
선언
public init( leCunUniform shape: TensorShape, seed: TensorFlowSeed = Context.local.randomSeed, on device: Device = .default )
매개변수
shape
텐서의 차원입니다.
seed
시드 값입니다.
LeCun normal 초기화를 수행하여 지정된 모양으로 텐서를 생성합니다.
이는 절두 정규 분포로부터 무작위 샘플 중심 무
0
표준 편차와sqrt(1 / fanIn)
기본 랜덤 넘버 생성기에 의해 생성fanIn
입력의 수가 수용 필드의 크기를 곱한 기능을 나타낸다.참조 : "효율적인 BackProp"
선언
public init( leCunNormal shape: TensorShape, seed: TensorFlowSeed = Context.local.randomSeed, on device: Device = .default )
매개변수
shape
텐서의 차원입니다.
seed
시드 값입니다.
직교 행렬 또는 텐서를 생성합니다.
초기화할 텐서의 모양이 2차원인 경우 정규 분포에서 추출한 난수 행렬의 QR 분해에서 얻은 직교 행렬로 초기화됩니다. 행렬에 열보다 행이 적은 경우 출력에는 직교 행이 있습니다. 그렇지 않으면 출력에 직교 열이 있습니다.
초기화하는 텐서의 형태 인 경우보다 이차원보다 형상의 행렬
[shape[0] * ... * shape[rank - 2], shape[rank - 1]]
초기화된다. 행렬은 이후에 원하는 모양의 텐서를 제공하도록 재구성됩니다.선언
public init( orthogonal shape: TensorShape, gain: Tensor<Scalar> = Tensor<Scalar>(1), seed: TensorFlowSeed = Context.local.randomSeed )
매개변수
shape
텐서의 모양.
gain
직교 텐서에 적용할 승법 요소입니다.
seed
난수 생성기를 시드할 두 정수의 튜플입니다.
[배치] 텐서의 [배치] 대각선 부분을 반환합니다. 형상의 텐서 예컨대
[..., M, N]
, 출력이 형상의 텐서 인[..., K]
, 여기서K
동일min(N, M)
.예를 들어:
// 't' is [[1, 0, 0, 0] // [0, 2, 0, 0] // [0, 0, 3, 0] // [0, 0, 0, 4]] t.diagonalPart() // [1, 2, 3, 4]
선언
@differentiable public func diagonalPart() -> Tensor
[일괄 처리] 대각선 배열을 생성합니다. 형상의 텐서 예컨대
[..., M]
, 출력은 형상의 텐서 인[..., M, M]
.예를 들어:
// 't' is [1, 2, 3, 4] t.diagonal() // [[1, 0, 0, 0] // [0, 2, 0, 0] // [0, 0, 3, 0] // [0, 0, 0, 4]]
선언
@differentiable public func diagonal() -> Tensor
반환
self
새로운 대각 값, 주어진self
임의로 일괄 행렬이다.반환 텐서는 동일한 형상 및 값을 갖는
self
의 값에 의해 덮어 최 행렬의 대각선 지정된 제외한diagonal
.대각선 매개 변수 : 순위가있는 텐서
rank - 1
새로운 대각선 값을 나타내는.선언
public func withDiagonal(_ diagonal: Tensor<Scalar>) -> Tensor
선언
@differentiable(wrt: self) public func bandPart(_ subdiagonalCount: Int, _ superdiagonalCount: Int) -> Tensor
중앙 밴드 경계로 정의된 가장 안쪽 텐서의 복사본을 반환합니다. 출력은 예와 같은 형상의 텐서
[..., :, :]
.예를 들어:
// 't' is [[ 0, 1, 2, 3] // [-1, 0, 1, 2] // [-2, -1, 0, 1] // [-3, -2, -1, 0]] t.bandPart(1, -1) // [[ 0, 1, 2, 3] // [-1, 0, 1, 2] // [ 0, -1, 0, 1] // [ 0, 0, -1, 0]] t.bandPart(2, 1) // [[ 0, 1, 0, 0] // [-1, 0, 1, 0] // [-2, -1, 0, 1] // [ 0, -2, -1, 0]]
선언
@differentiable public func bandPart(subdiagonalCount: Int, superdiagonalCount: Int) -> Tensor
매개변수
subdiagonalCount
유지할 부분대각선의 수입니다. 음수이면 전체 아래쪽 삼각형을 유지합니다.
superdiagonalCount
유지할 초대각선의 수입니다. 음수이면 전체 위쪽 삼각형을 유지합니다.
반환 텐서의 각 내측 행렬의 QR 분해는, 내부 직교 행렬과 텐서
q
및 내측 상 삼각 행렬과 텐서는r
텐서가 동일하도록,matmul(q, r)
.선언
public func qrDecomposition(fullMatrices: Bool = false) -> ( q: Tensor<Scalar>, r: Tensor<Scalar> )
매개변수
fullMatrices
경우
true
, 전체 크기의 계산q
와r
. 그 밖에는 주요한 계산min(shape[rank - 1], shape[rank - 2])
의 열q
.반환의 특이 값 분해
self
주어진,self
임의로 일괄 행렬이다.임의로 일괄 행렬의 특이 값 분해 (SVD)
self
의 값이다s
,u
및v
와 같은 것을 :self[..., :, :] = u[..., :, :] • s[..., :, :].diagonal() • v[..., :, :].transposed()`
자기
must be a tensor with shape
..., M, N]. Let
K = 분 (M, N) '.전제조건
self
형상 텐서 있어야[..., M, N]
.선언
public func svd(computeUV: Bool = true, fullMatrices: Bool = false) -> ( s: Tensor<Scalar>, u: Tensor<Scalar>?, v: Tensor<Scalar>? )
매개변수
computeUV
경우
true
좌우 특이 벡터를 산출하고 반환u
및v
는 각각. 경우false
,nil
값으로 반환됩니다u
와v
.fullMatrices
경우
true
,u
및v
각각 형상을 가질[..., M, M]
및[..., N, N]
. 경우false
,u
및v
각각 형상을 가질[..., M, K]
및[..., K, N]
. 때 무시computeUV
false입니다.반환 값
- S : 단수 값, 형상
[..., K]
. 각 벡터 내에서 특이값은 내림차순으로 정렬됩니다. - u: 왼쪽 특이 벡터.
- v: 오른쪽 특이 벡터.
- S : 단수 값, 형상
의 제곱근
x
.경우 실제 유형의 경우,
x
마이너스 인 결과는.nan
. 복합 유형의 경우 음의 실수 축에 분기 절단이 있습니다.선언
@differentiable public static func sqrt(_ x: `Self`) -> Tensor<Scalar>
의 코사인
x
라디안에서 각도로 해석.선언
@differentiable public static func cos(_ x: `Self`) -> Tensor<Scalar>
의 사인
x
라디안에서 각도로 해석.선언
@differentiable public static func sin(_ x: `Self`) -> Tensor<Scalar>
의 탄젠트
x
라디안의 각도로 해석.선언
@differentiable public static func tan(_ x: `Self`) -> Tensor<Scalar>
의 역 코사인
x
라디안이다.선언
@differentiable public static func acos(_ x: `Self`) -> Tensor<Scalar>
의 역 사인
x
라디안이다.선언
@differentiable public static func asin(_ x: `Self`) -> Tensor<Scalar>
의 역 탄젠트
x
라디안이다.선언
@differentiable public static func atan(_ x: `Self`) -> Tensor<Scalar>
의 쌍곡선 코사인
x
.선언
@differentiable public static func cosh(_ x: `Self`) -> Tensor<Scalar>
의 쌍곡선 사인
x
.선언
@differentiable public static func sinh(_ x: `Self`) -> Tensor<Scalar>
쌍곡선 탄젠트
x
.선언
@differentiable public static func tanh(_ x: `Self`) -> Tensor<Scalar>
역 쌍곡선 코사인
x
.선언
@differentiable public static func acosh(_ x: `Self`) -> Tensor<Scalar>
역 쌍곡선 사인
x
.선언
@differentiable public static func asinh(_ x: `Self`) -> Tensor<Scalar>
The inverse hyperbolic tangent of
x
.선언
@differentiable public static func atanh(_ x: `Self`) -> Tensor<Scalar>
The exponential function applied to
x
, ore**x
.선언
@differentiable public static func exp(_ x: `Self`) -> Tensor<Scalar>
Two raised to to power
x
.선언
@differentiable public static func exp2(_ x: `Self`) -> Tensor<Scalar>
Ten raised to to power
x
.선언
@differentiable public static func exp10(_ x: `Self`) -> Tensor<Scalar>
exp(x) - 1
evaluated so as to preserve accuracy close to zero.선언
@differentiable public static func expm1(_ x: `Self`) -> Tensor<Scalar>
The natural logarithm of
x
.선언
@differentiable public static func log(_ x: `Self`) -> Tensor<Scalar>
The base-two logarithm of
x
.선언
@differentiable public static func log2(_ x: `Self`) -> Tensor<Scalar>
The base-ten logarithm of
x
.선언
@differentiable public static func log10(_ x: `Self`) -> Tensor<Scalar>
log(1 + x)
evaluated so as to preserve accuracy close to zero.선언
@differentiable public static func log1p(_ x: `Self`) -> Tensor<Scalar>
exp(y log(x))
computed without loss of intermediate precision.For real types, if
x
is negative the result is NaN, even ify
has an integral value. For complex types, there is a branch cut on the negative real axis.선언
@differentiable public static func pow(_ x: `Self`, _ y: `Self`) -> Tensor<Scalar>
x
raised to then
th power.The product of
n
copies ofx
.선언
@differentiable public static func pow(_ x: `Self`, _ n: Int) -> Tensor<Scalar>
The
n
th root ofx
.For real types, if
x
is negative andn
is even, the result is NaN. For complex types, there is a branch cut along the negative real axis.선언
@differentiable public static func root(_ x: `Self`, _ n: Int) -> Tensor<Scalar>
선언
public typealias VectorSpaceScalar = Float
선언
public func scaled(by scale: Float) -> Tensor<Scalar>
선언
public func adding(_ scalar: Float) -> Tensor<Scalar>
선언
public func subtracting(_ scalar: Float) -> Tensor<Scalar>
Adds the scalar to every scalar of the tensor and produces the sum.
선언
@differentiable public static func + (lhs: Scalar, rhs: Tensor) -> Tensor
Adds the scalar to every scalar of the tensor and produces the sum.
선언
@differentiable public static func + (lhs: Tensor, rhs: Scalar) -> Tensor
Subtracts the scalar from every scalar of the tensor and produces the difference.
선언
@differentiable public static func - (lhs: Scalar, rhs: Tensor) -> Tensor
Subtracts the scalar from every scalar of the tensor and produces the difference
선언
@differentiable public static func - (lhs: Tensor, rhs: Scalar) -> Tensor
Adds two tensors and stores the result in the left-hand-side variable.
메모
+=
supports broadcasting.선언
public static func += (lhs: inout Tensor, rhs: Tensor)
Adds the scalar to every scalar of the tensor and stores the result in the left-hand-side variable.
선언
public static func += (lhs: inout Tensor, rhs: Scalar)
Subtracts the second tensor from the first and stores the result in the left-hand-side variable.
메모
-=
supports broadcasting.선언
public static func -= (lhs: inout Tensor, rhs: Tensor)
Subtracts the scalar from every scalar of the tensor and stores the result in the left-hand-side variable.
선언
public static func -= (lhs: inout Tensor, rhs: Scalar)
Returns the tensor produced by multiplying the two tensors.
메모
*
supports broadcasting.선언
@differentiable public static func * (lhs: Tensor, rhs: Tensor) -> Tensor
Returns the tensor by multiplying it with every scalar of the tensor.
선언
@differentiable public static func * (lhs: Scalar, rhs: Tensor) -> Tensor
Multiplies the scalar with every scalar of the tensor and produces the product.
선언
@differentiable public static func * (lhs: Tensor, rhs: Scalar) -> Tensor
Multiplies two tensors and stores the result in the left-hand-side variable.
메모
*=
supports broadcasting.선언
public static func *= (lhs: inout Tensor, rhs: Tensor)
Multiplies the tensor with the scalar, broadcasting the scalar, and stores the result in the left-hand-side variable.
선언
public static func *= (lhs: inout Tensor, rhs: Scalar)
Returns the quotient of dividing the first tensor by the second.
메모
/
supports broadcasting.선언
@differentiable public static func / (lhs: Tensor, rhs: Tensor) -> Tensor
Returns the quotient of dividing the scalar by the tensor, broadcasting the scalar.
선언
@differentiable public static func / (lhs: Scalar, rhs: Tensor) -> Tensor
Returns the quotient of dividing the tensor by the scalar, broadcasting the scalar.
선언
@differentiable public static func / (lhs: Tensor, rhs: Scalar) -> Tensor
Divides the first tensor by the second and stores the quotient in the left-hand-side variable.
선언
public static func /= (lhs: inout Tensor, rhs: Tensor)
Divides the tensor by the scalar, broadcasting the scalar, and stores the quotient in the left-hand-side variable.
선언
public static func /= (lhs: inout Tensor, rhs: Scalar)
Returns the remainder of dividing the first tensor by the second.
메모
%
supports broadcasting.선언
public static func % (lhs: Tensor, rhs: Tensor) -> Tensor
Returns the remainder of dividing the tensor by the scalar, broadcasting the scalar.
선언
public static func % (lhs: Tensor, rhs: Scalar) -> Tensor
Returns the remainder of dividing the scalar by the tensor, broadcasting the scalar.
선언
public static func % (lhs: Scalar, rhs: Tensor) -> Tensor
Divides the first tensor by the second and stores the remainder in the left-hand-side variable.
선언
public static func %= (lhs: inout Tensor, rhs: Tensor)
Divides the tensor by the scalar and stores the remainder in the left-hand-side variable.
선언
public static func %= (lhs: inout Tensor, rhs: Scalar)
Returns
!self
element-wise.선언
public func elementsLogicalNot() -> Tensor
Returns
self && other
element-wise.메모
&&
supports broadcasting.선언
public func elementsLogicalAnd(_ other: Tensor) -> Tensor
Returns
self && other
element-wise, broadcastingother
.선언
public func elementsLogicalAnd(_ other: Scalar) -> Tensor
Returns
self || other
element-wise.선언
public func elementsLogicalOr(_ other: Tensor) -> Tensor
Returns
self || other
element-wise, broadcastingother
.선언
public func elementsLogicalOr(_ other: Scalar) -> Tensor
Returns
max(min(self, max), min)
.선언
@differentiable public func clipped(min: Tensor, max: Tensor) -> Tensor
Returns
max(min(self, max), min)
.선언
@differentiable(wrt: (self, min) ) public func clipped(min: Tensor, max: Scalar) -> Tensor
Returns
max(min(self, max), min)
.선언
@differentiable(wrt: (self, max) ) public func clipped(min: Scalar, max: Tensor) -> Tensor
Returns
max(min(self, max), min)
.선언
@differentiable(wrt: self) public func clipped(min: Scalar, max: Scalar) -> Tensor
Returns the negation of the specified tensor element-wise.
선언
@differentiable public prefix static func - (rhs: Tensor) -> Tensor
선언
@differentiable(wrt: self) public func squared() -> Tensor
Returns a boolean tensor indicating which elements of
x
are finite.선언
public var isFinite: Tensor<Bool> { get }
Returns a boolean tensor indicating which elements of
x
are infinite.선언
public var isInfinite: Tensor<Bool> { get }
Returns a boolean tensor indicating which elements of
x
are NaN-valued.선언
public var isNaN: Tensor<Bool> { get }
Returns
true
if all scalars are equal totrue
. Otherwise, returnsfalse
.선언
public func all() -> Bool
Returns
true
if any scalars are equal totrue
. Otherwise, returnsfalse
.선언
public func any() -> Bool
Performs a logical AND operation along the specified axes. The reduced dimensions are removed.
전제조건
Each value inaxes
must be in the range-rank..<rank
.선언
public func all(squeezingAxes axes: Int...) -> Tensor
매개변수
axes
The dimensions to reduce.
Performs a logical AND operation along the specified axes. The reduced dimensions are removed.
전제조건
Each value inaxes
must be in the range-rank..<rank
.선언
public func any(squeezingAxes axes: Int...) -> Tensor
매개변수
axes
The dimensions to reduce.
Performs a logical AND operation along the specified axes. The reduced dimensions are retained with value 1.
전제조건
Each value inaxes
must be in the range-rank..<rank
.선언
public func all(alongAxes axes: Int...) -> Tensor
매개변수
axes
The dimensions to reduce.
Performs a logical OR operation along the specified axes. The reduced dimensions are retained with value 1.
전제조건
Each value inaxes
must be in the range-rank..<rank
.선언
public func any(alongAxes axes: Int...) -> Tensor
매개변수
axes
The dimensions to reduce.
선언
@differentiable public func min() -> Tensor
선언
@differentiable public func max() -> Tensor
Returns the maximum values along the specified axes. The reduced dimensions are removed.
전제조건
Each value inaxes
must be in the range-rank..<rank
.선언
@differentiable(wrt: self) public func max(squeezingAxes axes: Tensor<Int32>) -> Tensor
매개변수
axes
The dimensions to reduce.
Returns the maximum values along the specified axes. The reduced dimensions are removed.
전제조건
Each value inaxes
must be in the range-rank..<rank
.선언
@differentiable(wrt: self) public func max(squeezingAxes axes: [Int]) -> Tensor
매개변수
axes
The dimensions to reduce.
Returns the maximum values along the specified axes. The reduced dimensions are removed.
전제조건
Each value inaxes
must be in the range-rank..<rank
.선언
@differentiable(wrt: self) public func max(squeezingAxes axes: Int...) -> Tensor
매개변수
axes
The dimensions to reduce.
Returns the minimum values along the specified axes. The reduced dimensions are removed.
전제조건
Each value inaxes
must be in the range-rank..<rank
.선언
@differentiable(wrt: self) public func min(squeezingAxes axes: Tensor<Int32>) -> Tensor
매개변수
axes
The dimensions to reduce.
Returns the minimum values along the specified axes. The reduced dimensions are removed.
전제조건
Each value inaxes
must be in the range-rank..<rank
.선언
@differentiable(wrt: self) public func min(squeezingAxes axes: [Int]) -> Tensor
매개변수
axes
The dimensions to reduce.
Returns the minimum values along the specified axes. The reduced dimensions are removed.
전제조건
Each value inaxes
must be in the range-rank..<rank
.선언
@differentiable(wrt: self) public func min(squeezingAxes axes: Int...) -> Tensor
매개변수
axes
The dimensions to reduce.
Returns the indices of the maximum values along the specified axes. The reduced dimensions are removed.
전제조건
Each value inaxes
must be in the range-rank..<rank
.선언
public func argmax(squeezingAxis axis: Int) -> Tensor<Int32>
매개변수
axes
The dimensions to reduce.
Returns the indices of the minimum values along the specified axes. The reduced dimensions are removed.
전제조건
Each value inaxes
must be in the range-rank..<rank
.선언
public func argmin(squeezingAxis axis: Int) -> Tensor<Int32>
매개변수
axes
The dimensions to reduce.
Returns the minimum along the specified axes. The reduced dimensions are retained with value 1.
전제조건
Each value inaxes
must be in the range-rank..<rank
.선언
@differentiable(wrt: self) public func min(alongAxes axes: Tensor<Int32>) -> Tensor
매개변수
axes
The dimensions to reduce.
Returns the minimum along the specified axes. The reduced dimensions are retained with value 1.
전제조건
Each value inaxes
must be in the range-rank..<rank
.선언
@differentiable(wrt: self) public func min(alongAxes axes: [Int]) -> Tensor
매개변수
axes
The dimensions to reduce.
Returns the minimum along the specified axes. The reduced dimensions are retained with value 1.
전제조건
Each value inaxes
must be in the range-rank..<rank
.선언
@differentiable(wrt: self) public func min(alongAxes axes: Int...) -> Tensor
매개변수
axes
The dimensions to reduce.
Returns the minimum along the specified axes. The reduced dimensions are retained with value 1.
전제조건
Each value inaxes
must be in the range-rank..<rank
.선언
@differentiable(wrt: self) public func max(alongAxes axes: Tensor<Int32>) -> Tensor
매개변수
axes
The dimensions to reduce.
Returns the minimum along the specified axes. The reduced dimensions are retained with value 1.
전제조건
Each value inaxes
must be in the range-rank..<rank
.선언
@differentiable(wrt: self) public func max(alongAxes axes: [Int]) -> Tensor
매개변수
axes
The dimensions to reduce.
Returns the minimum along the specified axes. The reduced dimensions are retained with value 1.
전제조건
Each value inaxes
must be in the range-rank..<rank
.선언
@differentiable(wrt: self) public func max(alongAxes axes: Int...) -> Tensor
매개변수
axes
The dimensions to reduce.
Returns the index of the maximum value of the flattened scalars.
선언
public func argmax() -> Tensor<Int32>
Returns the index of the minimum value of the flattened scalars.
선언
public func argmin() -> Tensor<Int32>
Returns the sum along the specified axes. The reduced dimensions are removed.
전제조건
Each value inaxes
must be in the range-rank...rank
.선언
@differentiable(wrt: self) public func sum(squeezingAxes axes: Tensor<Int32>) -> Tensor
매개변수
axes
The dimensions to reduce.
Returns the sum along the specified axes. The reduced dimensions are removed.
전제조건
Each value inaxes
must be in the range-rank...rank
.선언
@differentiable(wrt: self) public func sum(squeezingAxes axes: [Int]) -> Tensor
매개변수
axes
The dimensions to reduce.
Returns the sum along the specified axes. The reduced dimensions are removed.
전제조건
Each value inaxes
must be in the range-rank...rank
.선언
@differentiable(wrt: self) public func sum(squeezingAxes axes: Int...) -> Tensor
매개변수
axes
The dimensions to reduce.
선언
@differentiable(wrt: self) public func sum() -> Tensor
Returns the sum along the specified axes. The reduced dimensions are retained with value 1.
전제조건
Each value inaxes
must be in the range-rank..<rank
.선언
@differentiable(wrt: self) public func sum(alongAxes axes: Tensor<Int32>) -> Tensor
매개변수
axes
The dimensions to reduce.
Returns the sum along the specified axes. The reduced dimensions are retained with value 1.
전제조건
Each value inaxes
must be in the range-rank..<rank
.선언
@differentiable(wrt: self) public func sum(alongAxes axes: [Int]) -> Tensor
매개변수
axes
The dimensions to reduce.
Returns the sum along the specified axes. The reduced dimensions are retained with value 1.
전제조건
Each value inaxes
must be in the range-rank..<rank
.선언
@differentiable(wrt: self) public func sum(alongAxes axes: Int...) -> Tensor
매개변수
axes
The dimensions to reduce.
Returns the product along the specified axes. The reduced dimensions are removed.
전제조건
Each value inaxes
must be in the range-rank...rank
.선언
@differentiable(wrt: self) public func product(squeezingAxes axes: Tensor<Int32>) -> Tensor
매개변수
axes
The dimensions to reduce.
Returns the product along the specified axes. The reduced dimensions are removed.
전제조건
Each value inaxes
must be in the range-rank...rank
.선언
@differentiable(wrt: self) public func product(squeezingAxes axes: [Int]) -> Tensor
매개변수
axes
The dimensions to reduce.
Returns the product along the specified axes. The reduced dimensions are removed.
전제조건
Each value inaxes
must be in the range-rank...rank
.선언
@differentiable(wrt: self) public func product(squeezingAxes axes: Int...) -> Tensor
매개변수
axes
The dimensions to reduce.
선언
@differentiable(wrt: self) public func product() -> Tensor
Returns the product along the specified axes. The reduced dimensions are retained with value 1.
전제조건
Each value inaxes
must be in the range-rank..<rank
.선언
public func product(alongAxes axes: Tensor<Int32>) -> Tensor
매개변수
axes
The dimensions to reduce.
Returns the product along the specified axes. The reduced dimensions are retained with value 1.
전제조건
Each value inaxes
must be in the range-rank..<rank
.선언
public func product(alongAxes axes: [Int]) -> Tensor
매개변수
axes
The dimensions to reduce.
Returns the product along the specified axes. The reduced dimensions are retained with value 1.
전제조건
Each value inaxes
must be in the range-rank..<rank
.선언
public func product(alongAxes axes: Int...) -> Tensor
매개변수
axes
The dimensions to reduce.
Returns the arithmetic mean along the specified axes. The reduced dimensions are removed.
전제조건
Each value inaxes
must be in the range-rank...rank
.선언
@differentiable(wrt: self) public func mean(squeezingAxes axes: Tensor<Int32>) -> Tensor
매개변수
axes
The dimensions to reduce.
Returns the arithmetic mean along the specified axes. The reduced dimensions are removed.
전제조건
Each value inaxes
must be in the range-rank...rank
.선언
@differentiable(wrt: self) public func mean(squeezingAxes axes: [Int]) -> Tensor
매개변수
axes
The dimensions to reduce.
Returns the arithmetic mean along the specified axes. The reduced dimensions are removed.
전제조건
Each value inaxes
must be in the range-rank...rank
.선언
@differentiable(wrt: self) public func mean(squeezingAxes axes: Int...) -> Tensor
매개변수
axes
The dimensions to reduce.
선언
@differentiable(wrt: self) public func mean() -> Tensor
Returns the arithmetic mean along the specified axes. The reduced dimensions are retained with value 1.
전제조건
Each value inaxes
must be in the range-rank..<rank
.선언
@differentiable(wrt: self) public func mean(alongAxes axes: Tensor<Int32>) -> Tensor
매개변수
axes
The dimensions to reduce.
Returns the arithmetic mean along the specified axes. The reduced dimensions are retained with value 1.
전제조건
Each value inaxes
must be in the range-rank..<rank
.선언
@differentiable(wrt: self) public func mean(alongAxes axes: [Int]) -> Tensor
매개변수
axes
The dimensions to reduce.
Returns the arithmetic mean along the specified axes. The reduced dimensions are retained with value 1.
전제조건
Each value inaxes
must be in the range-rank..<rank
.선언
@differentiable(wrt: self) public func mean(alongAxes axes: Int...) -> Tensor
매개변수
axes
The dimensions to reduce.
Returns the variance along the specified axes. The reduced dimensions are removed. Does not apply Bessel's correction.
전제조건
Each value inaxes
must be in the range-rank..<rank
.선언
@differentiable(wrt: self) public func variance(squeezingAxes axes: Tensor<Int32>) -> Tensor
매개변수
axes
The dimensions to reduce.
Returns the variance along the specified axes. The reduced dimensions are removed. Does not apply Bessel's correction.
전제조건
Each value inaxes
must be in the range-rank..<rank
.선언
@differentiable(wrt: self) public func variance(squeezingAxes axes: [Int]) -> Tensor
매개변수
axes
The dimensions to reduce.
Returns the variance along the specified axes. The reduced dimensions are retained with value 1. Does not apply Bessel's correction.
전제조건
Each value inaxes
must be in the range-rank..<rank
.선언
@differentiable(wrt: self) public func variance(squeezingAxes axes: Int...) -> Tensor
매개변수
axes
The dimensions to reduce.
선언
@differentiable(wrt: self) public func variance() -> Tensor
Returns the variance along the specified axes. The reduced dimensions are retained with value 1. Does not apply Bessel's correction.
전제조건
Each value inaxes
must be in the range-rank..<rank
.선언
@differentiable(wrt: self) public func variance(alongAxes axes: Tensor<Int32>) -> Tensor
매개변수
axes
The dimensions to reduce.
Returns the variance along the specified axes. The reduced dimensions are retained with value 1. Does not apply Bessel's correction.
전제조건
Each value inaxes
must be in the range-rank..<rank
.선언
@differentiable(wrt: self) public func variance(alongAxes axes: [Int]) -> Tensor
매개변수
axes
The dimensions to reduce.
Returns the variance along the specified axes. The reduced dimensions are retained with value 1. Does not apply Bessel's correction.
전제조건
Each value inaxes
must be in the range-rank..<rank
.선언
@differentiable(wrt: self) public func variance(alongAxes axes: Int...) -> Tensor
매개변수
axes
The dimensions to reduce.
Returns the cumulative sum of this tensor along the specified axis. By default, this function performs an inclusive cumulative sum which means that the first element of the input is identical to the first element of the output:
Tensor<Float>([a, b, c]).cumulativeSum() = Tensor<Float>([a, a + b, a + b + c])
By setting the
exclusive
argument totrue
, an exclusive cumulative sum is performed instead:Tensor<Float>([a, b, c]).cumulativeSum(exclusive: true) = Tensor<Float>([0, a, a + b])
By setting the
reverse
argument totrue
, the cumulative sum is performed in the opposite direction:Tensor<Float>([a, b, c]).cumulativeSum(reverse: true) == Tensor<Float>([a + b + c, a + b, a])
This is more efficient than separately reversing the resulting tensor.
전제조건
axis
must be in the range-rank..<rank
.선언
@differentiable(wrt: self) public func cumulativeSum( alongAxis axis: Int, exclusive: Bool = false, reverse: Bool = false ) -> Tensor
매개변수
axis
Axis along which to perform the cumulative sum operation.
exclusive
Indicates whether to perform an exclusive cumulative sum.
reverse
Indicates whether to perform the cumulative sum in reversed order.
반환 값
Result of the cumulative sum operation.
Returns the cumulative sum of this tensor along the specified axis. By default, this function performs an inclusive cumulative sum which means that the first element of the input is identical to the first element of the output:
Tensor<Float>([a, b, c]).cumulativeSum() = Tensor<Float>([a, a + b, a + b + c])
By setting the
exclusive
argument totrue
, an exclusive cumulative sum is performed instead:Tensor<Float>([a, b, c]).cumulativeSum(exclusive: true) = Tensor<Float>([0, a, a + b])
By setting the
reverse
argument totrue
, the cumulative sum is performed in the opposite direction:Tensor<Float>([a, b, c]).cumulativeSum(reverse: true) == Tensor<Float>([a + b + c, a + b, a])
This is more efficient than separately reversing the resulting tensor.
전제조건
axis.rank
must be0
.전제조건
axis
must be in the range-rank..<rank
.선언
@differentiable(wrt: self) public func cumulativeSum( alongAxis axis: Tensor<Int32>, exclusive: Bool = false, reverse: Bool = false ) -> Tensor
매개변수
axis
Axis along which to perform the cumulative sum operation.
exclusive
Indicates whether to perform an exclusive cumulative sum.
reverse
Indicates whether to perform the cumulative sum in reversed order.
반환 값
Result of the cumulative sum operation.
Returns the cumulative product of this tensor along the specified axis. By default, this function performs an inclusive cumulative product which means that the first element of the input is identical to the first element of the output:
Tensor<Float>([a, b, c]).cumulativeProduct() = Tensor<Float>([a, a * b, a * b * c])
By setting the
exclusive
argument totrue
, an exclusive cumulative product is performed instead:Tensor<Float>([a, b, c]).cumulativeProduct(exclusive: true) = Tensor<Float>([1, a, a * b])
By setting the
reverse
argument totrue
, the cumulative product is performed in the opposite direction:Tensor<Float>([a, b, c]).cumulativeProduct(reverse: true) == Tensor<Float>([a * b * c, a * b, a])
This is more efficient than separately reversing the resulting tensor.
전제조건
axis
must be in the range-rank..<rank
.선언
@differentiable(wrt: self) public func cumulativeProduct( alongAxis axis: Int, exclusive: Bool = false, reverse: Bool = false ) -> Tensor
매개변수
axis
Axis along which to perform the cumulative product operation.
exclusive
Indicates whether to perform an exclusive cumulative product.
reverse
Indicates whether to perform the cumulative product in reversed order.
반환 값
Result of the cumulative product operation.
Returns the cumulative product of this tensor along the specified axis. By default, this function performs an inclusive cumulative product which means that the first element of the input is identical to the first element of the output:
Tensor<Float>([a, b, c]).cumulativeProduct() = Tensor<Float>([a, a * b, a * b * c])
By setting the
exclusive
argument totrue
, an exclusive cumulative product is performed instead:Tensor<Float>([a, b, c]).cumulativeProduct(exclusive: true) = Tensor<Float>([1, a, a * b])
By setting the
reverse
argument totrue
, the cumulative product is performed in the opposite direction:Tensor<Float>([a, b, c]).cumulativeProduct(reverse: true) == Tensor<Float>([a * b * c, a * b, a])
This is more efficient than separately reversing the resulting tensor.
전제조건
axis
must have rank0
.전제조건
axis
must be in the range-rank..<rank
.선언
@differentiable(wrt: self) public func cumulativeProduct( alongAxis axis: Tensor<Int32>, exclusive: Bool = false, reverse: Bool = false ) -> Tensor
매개변수
axis
Axis along which to perform the cumulative product operation.
exclusive
Indicates whether to perform an exclusive cumulative product.
reverse
Indicates whether to perform the cumulative product in reversed order.
반환 값
Result of the cumulative product operation.
Returns the standard deviation of the elements along the specified axes. The reduced dimensions are retained with value
1
. Does not apply Bessel's correction.전제조건
Each value inaxes
must be in the range-rank..<rank
.선언
@differentiable(wrt: self) public func standardDeviation(squeezingAxes axes: Tensor<Int32>) -> Tensor
매개변수
axes
The dimensions to reduce.
Returns the standard deviation of the elements along the specified axes. The reduced dimensions are retained with value
1
. Does not apply Bessel's correction.전제조건
Each value inaxes
must be in the range-rank..<rank
.선언
@differentiable(wrt: self) public func standardDeviation(squeezingAxes axes: [Int]) -> Tensor
매개변수
axes
The dimensions to reduce.
Returns the standard deviation of the elements along the specified axes. The reduced dimensions are retained with value
1
. Does not apply Bessel's correction.전제조건
Each value inaxes
must be in the range-rank..<rank
.선언
@differentiable(wrt: self) public func standardDeviation(squeezingAxes axes: Int...) -> Tensor
매개변수
axes
The dimensions to reduce.
Returns the standard deviation of all elements in this tensor. Does not apply Bessel's correction.
전제조건
Each value inaxes
must be in the range-rank..<rank
.선언
@differentiable(wrt: self) public func standardDeviation() -> Tensor
Returns the standard deviation of the elements along the specified axes. The reduced dimensions are retained with value
1
. Does not apply Bessel's correction.전제조건
Each value inaxes
must be in the range-rank..<rank
.선언
@differentiable(wrt: self) public func standardDeviation(alongAxes axes: Tensor<Int32>) -> Tensor
매개변수
axes
The dimensions to reduce.
Returns the standard deviation of the elements along the specified axes. The reduced dimensions are retained with value
1
. Does not apply Bessel's correction.전제조건
Each value inaxes
must be in the range-rank..<rank
.선언
@differentiable(wrt: self) public func standardDeviation(alongAxes axes: [Int]) -> Tensor
매개변수
axes
The dimensions to reduce.
Returns the standard deviation of the elements along the specified axes. The reduced dimensions are retained with value
1
. Does not apply Bessel's correction.전제조건
Each value inaxes
must be in the range-rank..<rank
.선언
@differentiable(wrt: self) public func standardDeviation(alongAxes axes: Int...) -> Tensor
매개변수
axes
The dimensions to reduce.
Returns
log(exp(self).sum(squeezingAxes: axes))
. The reduced dimensions are removed.This function is more numerically stable than computing
log(exp(self).sum(squeezingAxes: axes))
directly. It avoids overflows caused by computing theexp
of large inputs and underflows caused by computing thelog
of small inputs.전제조건
Each value inaxes
must be in the range-rank..<rank
.선언
@differentiable(wrt: self) public func logSumExp(squeezingAxes axes: Tensor<Int32>) -> Tensor
매개변수
axes
The dimensions to reduce.
Returns
log(exp(self).sum(squeezingAxes: axes))
. The reduced dimensions are removed.This function is more numerically stable than computing
log(exp(self).sum(squeezingAxes: axes))
directly. It avoids overflows caused by computing theexp
of large inputs and underflows caused by computing thelog
of small inputs.전제조건
Each value inaxes
must be in the range-rank..<rank
.선언
@differentiable(wrt: self) public func logSumExp(squeezingAxes axes: [Int]) -> Tensor
매개변수
axes
The dimensions to reduce.
Returns
log(exp(self).sum(squeezingAxes: axes))
. The reduced dimensions are removed.This function is more numerically stable than computing
log(exp(self).sum(squeezingAxes: axes))
directly. It avoids overflows caused by computing theexp
of large inputs and underflows caused by computing thelog
of small inputs.전제조건
Each value inaxes
must be in the range-rank..<rank
.선언
@differentiable(wrt: self) public func logSumExp(squeezingAxes axes: Int...) -> Tensor
매개변수
axes
The dimensions to reduce.
Returns
log(exp(self).sum())
. The result is a scalar.This function is more numerically stable than computing
log(exp(self).sum())
directly. It avoids overflows caused by computing theexp
of large inputs and underflows caused by computing thelog
of small inputs.선언
@differentiable(wrt: self) public func logSumExp() -> Tensor
Returns
log(exp(self).sum(alongAxes: axes))
. The reduced dimensions are retained with value1
.This function is more numerically stable than computing
log(exp(self).sum(alongAxes: axes))
directly. It avoids overflows caused by computing theexp
of large inputs and underflows caused by computing thelog
of small inputs.전제조건
Each value inaxes
must be in the range-rank..<rank
.선언
@differentiable(wrt: self) public func logSumExp(alongAxes axes: Tensor<Int32>) -> Tensor
매개변수
axes
The dimensions to reduce.
Returns
log(exp(self).sum(alongAxes: axes))
. The reduced dimensions are retained with value1
.This function is more numerically stable than computing
log(exp(self).sum(alongAxes: axes))
directly. It avoids overflows caused by computing theexp
of large inputs and underflows caused by computing thelog
of small inputs.전제조건
Each value inaxes
must be in the range-rank..<rank
.선언
@differentiable(wrt: self) public func logSumExp(alongAxes axes: [Int]) -> Tensor
매개변수
axes
The dimensions to reduce.
Returns
log(exp(self).sum(alongAxes: axes))
. The reduced dimensions are retained with value1
.This function is more numerically stable than computing
log(exp(self).sum(alongAxes: axes))
directly. It avoids overflows caused by computing theexp
of large inputs and underflows caused by computing thelog
of small inputs.전제조건
Each value inaxes
must be in the range-rank..<rank
.선언
@differentiable(wrt: self) public func logSumExp(alongAxes axes: Int...) -> Tensor
매개변수
axes
The dimensions to reduce.
Returns the mean and variance of this tensor along the specified axes. The reduced dimensions are removed.
전제조건
axes
must have rank1
.전제조건
Each value inaxes
must be in the range-rank..<rank
.선언
@differentiable(wrt: self) public func moments(squeezingAxes axes: Tensor<Int32>) -> Moments<Scalar>
매개변수
axes
The dimensions to reduce.
Returns the mean and variance of this tensor along the specified axes. The reduced dimensions are removed.
전제조건
Each value inaxes
must be in the range-rank..<rank
.선언
@differentiable(wrt: self) public func moments(squeezingAxes axes: [Int]) -> Moments<Scalar>
매개변수
axes
The dimensions to reduce.
Returns the mean and variance of this tensor along the specified axes. The reduced dimensions are removed.
전제조건
Each value inaxes
must be in the range-rank..<rank
.선언
@differentiable(wrt: self) public func moments(squeezingAxes axes: Int...) -> Moments<Scalar>
매개변수
axes
The dimensions to reduce.
Returns the mean and variance of this tensor's elements.
선언
@differentiable(wrt: self) public func moments() -> Moments<Scalar>
Returns the mean and variance of this tensor along the specified axes. The reduced dimensions are retained with value
1
.전제조건
axes
must have rank1
.전제조건
Each value inaxes
must be in the range-rank..<rank
.선언
@differentiable(wrt: self) public func moments(alongAxes axes: Tensor<Int32>) -> Moments<Scalar>
매개변수
axes
The dimensions to reduce.
Returns the mean and variance of this tensor along the specified axes. The reduced dimensions are retained with value
1
.전제조건
Each value inaxes
must be in the range-rank..<rank
.선언
@differentiable(wrt: self) public func moments(alongAxes axes: [Int]) -> Moments<Scalar>
매개변수
axes
The dimensions to reduce.
Returns the mean and variance of this tensor along the specified axes. The reduced dimensions are retained with value
1
.전제조건
Each value inaxes
must be in the range-rank..<rank
.선언
@differentiable(wrt: self) public func moments(alongAxes axes: Int...) -> Moments<Scalar>
매개변수
axes
The dimensions to reduce.
Performs matrix multiplication between two tensors and produces the result.
선언
@differentiable public static func • (lhs: Tensor, rhs: Tensor) -> Tensor
선언
static func vjpInitDeviceAndPrecisionLike( _ value: Scalar, deviceAndPrecisionLike tensor: Tensor ) -> (value: Tensor, pullback: (Tensor) -> (Scalar, Tensor))
Returns a tensor computed from batch-normalizing the input along the specified axis.
Specifically, returns
(self - mu) / (var + epsilon) * gamma + beta
wheremu
andvar
are respectively the mean and variance ofself
alongaxis
.선언
@differentiable(wrt: (self, offset, scale) public func batchNormalized( alongAxis axis: Int, offset: Tensor = Tensor(0), scale: Tensor = Tensor(1), epsilon: Scalar = 0.001 ) -> Tensor
매개변수
axis
The batch dimension.
offset
The offset, also known as beta.
scale
The scale, also known as gamma.
epsilon
A small value added to the denominator for numerical stability.
Concatenates two tensors along last axis.
선언
@differentiable public static func concatenate(_ lhs: Tensor, _ rhs: Tensor) -> Tensor
Adds two values and produces their sum.
선언
@differentiable public static func sum(_ lhs: Tensor, _ rhs: Tensor) -> Tensor
Averages two values.
선언
@differentiable public static func average(_ lhs: Tensor, _ rhs: Tensor) -> Tensor
Multiplies two values.
선언
@differentiable public static func multiply(_ lhs: Tensor, _ rhs: Tensor) -> Tensor
Stack two values.
선언
@differentiable public static func stack(_ lhs: Tensor, _ rhs: Tensor) -> Tensor
선언
@derivative init(shape: scalars)
선언
public static func == (lhs: Tensor, rhs: Tensor) -> Bool
선언
public static func != (lhs: Tensor, rhs: Tensor) -> Bool
선언
public func encode(to encoder: Encoder) throws
선언
public init(from decoder: Decoder) throws
The scalar zero tensor.
선언
public static var zero: Tensor { get }
Adds two tensors and produces their sum.
메모
+
supports broadcasting.선언
@differentiable public static func + (lhs: Tensor, rhs: Tensor) -> Tensor
Subtracts one tensor from another and produces their difference.
메모
-
supports broadcasting.선언
@differentiable public static func - (lhs: Tensor, rhs: Tensor) -> Tensor
The scalar one tensor.
선언
public static var one: Tensor { get }
Returns the element-wise reciprocal of
self
.선언
public var reciprocal: Tensor { get }
Multiplies two tensors element-wise and produces their product.
메모
.*
supports broadcasting.선언
public static func .* (lhs: Tensor, rhs: Tensor) -> Tensor
선언
public typealias TangentVector = Tensor
선언
public var zeroTangentVectorInitializer: () -> TangentVector { get }
Adds an annotation.
Note: Only X10 is supported. For other backends, umodified
self
is returned.선언
@differentiable(wrt: self) public func annotate(_ annotation: String) -> Tensor<Scalar>
매개변수
annotation
The annotation to be added.
반환 값
The annotated tensor.
선언
@derivative func vjpAnnotate(_ annotation: String) -> ( value: Tensor<Scalar>, pullback: (Tensor<Scalar>) -> Tensor<Scalar> )