@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>)
unpacks มิติที่ได้รับของ rank-
R
เมตริกซ์เข้า rank- หลาย(R-1)
เทนเซอร์ unpacksN
เทนเซอร์จากเมตริกซ์นี้โดยบิ่นมันไปตามaxis
มิติที่N
จะอนุมานจากรูปร่างของเมตริกซ์นี้ ตัวอย่างเช่นกำหนดเมตริกซ์ที่มีรูปร่าง[A, B, C, D]
:- หาก
axis == 0
แล้วi
-th เมตริกซ์ในอาร์เรย์กลับเป็นชิ้นself[i, :, :, :]
และแต่ละเมตริกซ์ในอาร์เรย์ที่จะมีรูปร่าง[B, C, D]
(หมายเหตุว่ามิติห่อพร้อมจะหายไปไม่เหมือนTensor.split(numSplits:alongAxis)
หรือTensor.split(sizes:alongAxis)
) - หาก
axis == 1
แล้วi
-th เมตริกซ์ในอาร์เรย์กลับเป็นชิ้นvalue[:, i, :, :]
และแต่ละเมตริกซ์ในอาร์เรย์ที่จะมีรูปร่าง[A, C, D]
- เป็นต้น
นี่คือตรงข้ามของ
Tensor.init(stacking:alongAxis:)
เงื่อนไขเบื้องต้น
axis
จะต้องอยู่ในช่วง[-rank, rank)
ที่rank
เป็นยศเทนเซอร์ที่มีให้ประกาศ
@differentiable public func unstacked(alongAxis axis: Int = 0) -> [Tensor]
พารามิเตอร์
axis
มิติข้อมูลที่จะแตกออก ค่าลบล้อมรอบ
คืนมูลค่า
Array ที่มีเทนเซอร์แบบ unstacked
- หาก
แบ่งเทนเซอร์ออกเป็นหลายเมตริกซ์ เมตริกซ์เป็นแยกตามมิติ
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
ชิ้น -th มีรูปร่างเช่นเดียวกับเมตริกซ์นี้ยกเว้นตามมิติ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-D ที่มีขนาดของแต่ละส่วน
axis
มิติตามที่จะแยกเมตริกซ์นี้ ค่าลบล้อมรอบ
คืนมูลค่า
อาร์เรย์ที่ประกอบด้วยส่วนเทนเซอร์
ประกาศ
@differentiable(wrt: self) public func split(sizes: [Int], alongAxis axis: Int = 0) -> [Tensor]
ส่งกลับค่าเทนเซอร์แบบเรียงต่อกัน ซึ่งสร้างโดยการปูกระเบื้องเมตริกซ์นี้
คอนสตรัคนี้จะสร้างเมตริกซ์ใหม่โดยจำลองนี้เมตริกซ์
multiples
ครั้ง เมตริกซ์สร้างเป็นi
'มิติ TH มีself.shape[i] * multiples[i]
องค์ประกอบและค่านิยมของเมตริกซ์นี้ถูกจำลองแบบmultiples[i]
ครั้งตามi
' มิติ TH ยกตัวอย่างเช่นการปูกระเบื้อง[abcd]
โดย[2]
ผลิต[abcdabcd]
เงื่อนไขเบื้องต้น
รูปร่างของmultiples
ต้อง[tensor.rank]
เงื่อนไขเบื้องต้น
สเกลาทั้งหมดในmultiples
จะต้องไม่เป็นลบประกาศ
@differentiable(wrt: self) public func tiled(multiples: [Int]) -> Tensor
ส่งกลับค่าเทนเซอร์แบบเรียงต่อกัน ซึ่งสร้างโดยการปูกระเบื้องเมตริกซ์นี้
คอนสตรัคนี้จะสร้างเมตริกซ์ใหม่โดยจำลองนี้เมตริกซ์
multiples
ครั้ง เมตริกซ์สร้างเป็นi
'มิติ TH มีself.shape[i] * multiples[i]
องค์ประกอบและค่านิยมของเมตริกซ์นี้ถูกจำลองแบบmultiples[i]
ครั้งตามi
' มิติ TH ยกตัวอย่างเช่นการปูกระเบื้อง[abcd]
โดย[2]
ผลิต[abcdabcd]
เงื่อนไขเบื้องต้น
รูปร่างของmultiples
ต้อง[tensor.rank]
ประกาศ
@differentiable(wrt: self) public func tiled(multiples: Tensor<Int32>) -> Tensor
Reshape กับรูปร่างของที่ระบุ
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
Reshape เพื่อระบุ
Tensor
เป็นตัวแทนของรูปร่างเงื่อนไขเบื้องต้น
จำนวนสเกลาร์ตรงกับรูปร่างใหม่ประกาศ
@differentiable(wrt: self) public func reshaped(toShape newShape: Tensor<Int32>) -> Tensor
กลับสำเนาของเมตริกซ์ทรุดลง 1 มิติ
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
ที่มีมิติชั้นนำของ 1ประกาศ
@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
ตัวดำเนินการต่อ
บันทึก
++
เป็นผู้ประกอบการที่กำหนดเองที่ไม่ได้อยู่ในสวิฟท์ แต่ไม่อยู่ใน Haskell / สกาล่า การเพิ่มดังกล่าวไม่ใช่การเปลี่ยนแปลงภาษาที่ไม่มีนัยสำคัญและอาจเป็นข้อขัดแย้งได้ การดำรงอยู่ / การตั้งชื่อของ++
จะมีการหารือในระหว่างขั้นตอนการออกแบบ 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
's รูปร่างต้องตรงกับมิติภาคแรกของtensor
ของรูปร่าง แล้วเรามี:tensor.gathering(where: mask)[i, j1, ..., jd] = tensor[i1, ..., iK, j1, ..., jd]
ที่[i1, ..., iK]
เป็นi
วัน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
ส่งกลับตำแหน่งของค่าที่ไม่ใช่ศูนย์/ค่าจริงในเทนเซอร์นี้
พิกัดจะถูกส่งกลับในเมตริกซ์ 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
หรือจะเป็น 1-DTensor
ดังกล่าวว่าmask.scalarCount == self.shape[0]
ประกาศ
@differentiable(wrt: (self, other) ) public func replacing(with other: Tensor, where mask: Tensor<Bool>) -> Tensor
ส่งคืนค่าจริงหากประเภทสเกลาร์ทางกายภาพมีความแม่นยำลดลง
ปัจจุบันความแม่นยำลดลงประเภทเกลาทางกายภาพรวมเฉพาะ
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 }
ยศเมตริกซ์ที่แสดงเป็น
Tensor<Int32>
ประกาศ
public var rankTensor: Tensor<Int32> { get }
ขนาดของเมตริกซ์ที่แสดงเป็น
Tensor<Int32>
ประกาศ
public var shapeTensor: Tensor<Int32> { get }
จำนวนของสเกลาในเมตริกซ์ที่แสดงเป็น
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-D จากค่าสเกลาร์
ประกาศ
@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
ถ้าเป็นจริงสรุปคำอธิบายถ้านับองค์ประกอบเกินสองครั้ง
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)
ประกาศ
@derivative init(repeating: shape)
ดำเนินการแปลงชนิดองค์ประกอบที่ชาญฉลาดจาก
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)
สร้างเทนเซอร์โดยตั้งค่าสเกลาร์ทั้งหมดเป็นศูนย์
ประกาศ
public init(zeros shape: TensorShape, on device: Device = .default)
พารามิเตอร์
shape
รูปร่างของเทนเซอร์
สร้างเทนเซอร์โดยตั้งค่าสเกลาร์ทั้งหมดเป็นหนึ่ง
ประกาศ
public init(ones shape: TensorShape, on device: Device = .default)
พารามิเตอร์
shape
รูปร่างของเทนเซอร์
สร้างเทนเซอร์โดยตั้งค่าสเกลาร์ทั้งหมดเป็นศูนย์ที่มีรูปร่างและประเภทเดียวกันกับเทนเซอร์ที่ให้มา
ประกาศ
public init(zerosLike other: Tensor)
พารามิเตอร์
other
เทนเซอร์ที่มีรูปร่างและประเภทข้อมูลที่จะใช้
สร้างเมตริกซ์โดยตั้งค่าสเกลาร์ทั้งหมดเป็นเมตริกซ์ที่มีรูปร่างและประเภทเดียวกันกับเมตริกซ์ที่ให้มา
ประกาศ
public init(onesLike other: Tensor)
พารามิเตอร์
other
เทนเซอร์ที่มีรูปร่างและประเภทข้อมูลที่จะใช้
สร้างเทนเซอร์ 1-D ที่แสดงถึงลำดับจากค่าเริ่มต้นถึงแต่ไม่รวมค่าสิ้นสุด การก้าวตามจำนวนที่ระบุ
ประกาศ
public init( rangeFrom start: Scalar, to end: Scalar, stride: Scalar, on device: Device = .default )
พารามิเตอร์
start
ค่าเริ่มต้นที่จะใช้สำหรับลำดับ หากลำดับมีค่าใด ๆ ที่หนึ่งคือ
start
end
ค่าสิ้นสุดเพื่อจำกัดลำดับ
end
ไม่เคยองค์ประกอบของลำดับส่งผลให้ได้stride
จำนวนเงินที่ต้องทีละขั้นตอนกับการวนซ้ำแต่ละครั้ง
stride
ต้องเป็นบวกสร้างเทนเซอร์ 1-D ที่แสดงถึงลำดับจากค่าเริ่มต้นถึงแต่ไม่รวมค่าสิ้นสุด การก้าวตามจำนวนที่ระบุ
ประกาศ
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
, เมตริกซ์ใหม่จะมีอันดับที่ 1n+1
แกนใหม่จะถูกสร้างขึ้นในมิติaxis
(โดยค่าเริ่มต้นแกนใหม่จะถูกผนวกที่สิ้นสุด)หาก
indices
เป็นสเกลารูปร่างเมตริกซ์ใหม่จะเป็นเวกเตอร์ของความยาวdepth
หาก
indices
เป็นเวกเตอร์ของความยาวfeatures
รูปร่างออกจะเป็น: คุณลักษณะ x ลึกถ้าแกน == -1 x ลึกคุณลักษณะถ้าแกน == 0หาก
indices
เป็นเมทริกซ์ (batch) ที่มีรูปร่าง[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-D ที่แสดงลำดับจากค่าเริ่มต้น จนถึงและรวมค่าสิ้นสุด โดยเว้นระยะห่างเท่าๆ กันเพื่อสร้างจำนวนค่าที่ระบุ
ประกาศ
public init( linearSpaceFrom start: Scalar, to end: Scalar, count: Int, on device: Device = .default )
พารามิเตอร์
start
ค่าเริ่มต้นที่จะใช้สำหรับลำดับ หากลำดับมีค่าใด ๆ ที่หนึ่งคือ
start
end
ค่าสิ้นสุดเพื่อจำกัดลำดับ
end
เป็นองค์ประกอบสุดท้ายของลำดับที่เกิดcount
จำนวนค่าในลำดับผลลัพธ์
count
ต้องเป็นบวกสร้างเทนเซอร์ 1-D ที่แสดงลำดับจากค่าเริ่มต้น จนถึงและรวมค่าสิ้นสุด โดยเว้นระยะห่างเท่าๆ กันเพื่อสร้างจำนวนค่าที่ระบุ
เงื่อนไขเบื้องต้น
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, :]
หมายถึงความน่าจะเป็นบันทึก unnormalized สำหรับทุกชั้นsampleCount
0-D. จำนวนตัวอย่างอิสระที่จะวาดสำหรับแต่ละแถว
seed
ค่าเมล็ด.
คืนมูลค่า
2-D เทนเซอร์ที่มีรูปร่าง
[batchSize, sampleCount]
แต่ละชิ้น[i, :]
มีป้ายชื่อชั้นวาดด้วยช่วง[0, classCount)
สร้างเทนเซอร์ที่มีรูปร่างที่กำหนดโดยดำเนินการเริ่มต้นแบบสม่ำเสมอของ Glorot (Xavier)
มันดึงตัวอย่างที่สุ่มจากเครื่องแบบกระจายระหว่าง
-limit
และlimit
ที่เกิดจากเครื่องกำเนิดไฟฟ้าจำนวนสุ่มเริ่มต้นที่limit
คือsqrt(6 / (fanIn + fanOut))
และfanIn
/fanOut
แทนจำนวน input และ output คุณลักษณะคูณด้วยเปิดกว้าง ขนาดสนาม.อ้างอิง: “การทำความเข้าใจความยากลำบากของการฝึกอบรมเครือข่ายประสาทลึกคราทว่า”
ประกาศ
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
แทนจำนวน input และ output คุณลักษณะคูณด้วยลานรับสัญญาณ ขนาด.อ้างอิง: “การทำความเข้าใจความยากลำบากของการฝึกอบรมเครือข่ายประสาทลึกคราทว่า”
ประกาศ
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
หมายถึงจำนวนของการป้อนข้อมูลคุณลักษณะคูณด้วยขนาดที่ลานรับสัญญาณอ้างอิง: “Delving ลึกเข้าไปในวงจรเรียงกระแส: เหนือกว่าประสิทธิภาพของมนุษย์ระดับบน ImageNet การจัดหมวดหมู่”
ประกาศ
public init( heUniform shape: TensorShape, seed: TensorFlowSeed = Context.local.randomSeed, on device: Device = .default )
พารามิเตอร์
shape
ขนาดของเทนเซอร์
seed
ค่าเมล็ด.
สร้างเทนเซอร์ที่มีรูปร่างที่ระบุโดยดำเนินการเริ่มต้นปกติของ He (Kaiming)
มันดึงตัวอย่างที่สุ่มจากการกระจายปกติตัดทอนศูนย์กลางอยู่ที่
0
มีค่าเบี่ยงเบนมาตรฐานsqrt(2 / fanIn))
ที่สร้างโดยเครื่องกำเนิดไฟฟ้าจำนวนสุ่มเริ่มต้นที่fanIn
หมายถึงจำนวนของการป้อนข้อมูลคุณลักษณะคูณด้วยขนาดที่ลานรับสัญญาณอ้างอิง: “Delving ลึกเข้าไปในวงจรเรียงกระแส: เหนือกว่าประสิทธิภาพของมนุษย์ระดับบน ImageNet การจัดหมวดหมู่”
ประกาศ
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
มันดึงตัวอย่างที่สุ่มจากการกระจายปกติตัดทอนศูนย์กลางอยู่ที่
0
มีค่าเบี่ยงเบนมาตรฐานsqrt(1 / fanIn)
สร้างโดยเครื่องกำเนิดไฟฟ้าจำนวนสุ่มเริ่มต้นที่fanIn
หมายถึงจำนวนของการป้อนข้อมูลคุณลักษณะคูณด้วยขนาดที่ลานรับสัญญาณอ้างอิง: “ที่มีประสิทธิภาพ BackProp”
ประกาศ
public init( leCunNormal shape: TensorShape, seed: TensorFlowSeed = Context.local.randomSeed, on device: Device = .default )
พารามิเตอร์
shape
ขนาดของเทนเซอร์
seed
ค่าเมล็ด.
สร้างเมทริกซ์หรือเทนเซอร์มุมฉาก
หากรูปร่างของเทนเซอร์ที่จะเริ่มต้นเป็นแบบสองมิติ ก็จะเริ่มต้นด้วยเมทริกซ์มุมฉากที่ได้จากการสลายตัวของ 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
ทูเพิลของจำนวนเต็มสองจำนวนเพื่อสร้างตัวสร้างตัวเลขสุ่ม
ส่งกลับ [batched] ส่วนในแนวทแยงของ [batch] tensor สำหรับอินสแตนซ์เทนเซอร์ของรูปร่าง
[..., 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
สร้างอาร์เรย์แนวทแยง [batched] สำหรับอินสแตนซ์เทนเซอร์ของรูปร่าง
[..., 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
จำนวน superdiagonals ที่จะเก็บไว้ หากเป็นลบ ให้เก็บสามเหลี่ยมบนทั้งหมดไว้
ผลตอบแทน 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,. 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
เป็นเท็จคืนมูลค่า
- S: ค่าเอกพจน์ที่มีรูปร่าง
[..., K]
ภายในเวกเตอร์แต่ละตัว ค่าเอกพจน์จะเรียงลำดับจากมากไปหาน้อย - u: เวกเตอร์เอกพจน์ทางซ้าย
- v: เวกเตอร์เอกพจน์ที่ถูกต้อง
- S: ค่าเอกพจน์ที่มีรูปร่าง
รากที่สองของ
x
For real types, if
x
is negative the result is.nan
. For complex types there is a branch cut on the negative real axis.ประกาศ
@differentiable public static func sqrt(_ x: `Self`) -> Tensor<Scalar>
The cosine of
x
, interpreted as an angle in radians.ประกาศ
@differentiable public static func cos(_ x: `Self`) -> Tensor<Scalar>
The sine of
x
, interpreted as an angle in radians.ประกาศ
@differentiable public static func sin(_ x: `Self`) -> Tensor<Scalar>
The tangent of
x
, interpreted as an angle in radians.ประกาศ
@differentiable public static func tan(_ x: `Self`) -> Tensor<Scalar>
The inverse cosine of
x
in radians.ประกาศ
@differentiable public static func acos(_ x: `Self`) -> Tensor<Scalar>
The inverse sine of
x
in radians.ประกาศ
@differentiable public static func asin(_ x: `Self`) -> Tensor<Scalar>
The inverse tangent of
x
in radians.ประกาศ
@differentiable public static func atan(_ x: `Self`) -> Tensor<Scalar>
The hyperbolic cosine of
x
.ประกาศ
@differentiable public static func cosh(_ x: `Self`) -> Tensor<Scalar>
The hyperbolic sine of
x
.ประกาศ
@differentiable public static func sinh(_ x: `Self`) -> Tensor<Scalar>
The hyperbolic tangent of
x
.ประกาศ
@differentiable public static func tanh(_ x: `Self`) -> Tensor<Scalar>
The inverse hyperbolic cosine of
x
.ประกาศ
@differentiable public static func acosh(_ x: `Self`) -> Tensor<Scalar>
The inverse hyperbolic sine of
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.
Note
+=
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.
Note
-=
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.
Note
*
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.
Note
*=
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.
Note
/
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.
Note
%
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.Note
&&
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.
Precondition
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.
Precondition
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.
Precondition
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.
Precondition
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.
Precondition
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.
Precondition
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.
Precondition
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.
Precondition
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.
Precondition
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.
Precondition
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.
Precondition
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.
Precondition
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.
Precondition
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.
Precondition
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.
Precondition
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.
Precondition
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.
Precondition
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.
Precondition
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.
Precondition
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.
Precondition
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.
Precondition
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.
Precondition
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.
Precondition
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.
Precondition
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.
Precondition
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.
Precondition
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.
Precondition
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.
Precondition
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.
Precondition
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.
Precondition
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.
Precondition
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.
Precondition
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.
Precondition
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.
Precondition
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.
Precondition
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.
Precondition
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.
Precondition
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.
Precondition
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.
Precondition
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.
Precondition
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.
Precondition
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.
Precondition
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.
Precondition
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.
Precondition
axis.rank
must be0
.Precondition
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.
Precondition
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.
Precondition
axis
must have rank0
.Precondition
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.Precondition
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.Precondition
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.Precondition
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.
Precondition
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.Precondition
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.Precondition
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.Precondition
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.Precondition
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.Precondition
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.Precondition
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.Precondition
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.Precondition
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.Precondition
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.
Precondition
axes
must have rank1
.Precondition
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.
Precondition
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.
Precondition
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
.Precondition
axes
must have rank1
.Precondition
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
.Precondition
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
.Precondition
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
บวกค่าสองค่าและสร้างผลรวม
ประกาศ
@differentiable public static func sum(_ lhs: Tensor, _ rhs: Tensor) -> Tensor
ค่าเฉลี่ยสองค่า
ประกาศ
@differentiable public static func average(_ lhs: Tensor, _ rhs: Tensor) -> Tensor
คูณสองค่า
ประกาศ
@differentiable public static func multiply(_ lhs: Tensor, _ rhs: Tensor) -> Tensor
สแต็คสองค่า
ประกาศ
@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.
Note
+
supports broadcasting.ประกาศ
@differentiable public static func + (lhs: Tensor, rhs: Tensor) -> Tensor
Subtracts one tensor from another and produces their difference.
Note
-
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.
Note
.*
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> )