@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
Vektörlerin ve matrislerin potansiyel olarak daha yüksek boyutlara genelleştirilmesi olan çok boyutlu bir öğe dizisi.
Genel parametre Scalar
(örneğin tensörünün skaler türünü tarif Int32
, Float
, vb).
Altta yatan
TensorHandle
.Not
handle
kullanıcı tanımlı op izin geneldir ancak normalde kullanılmamalıdır.beyanname
public let handle: TensorHandle<Scalar>
beyanname
public init(handle: TensorHandle<Scalar>)
Bir rank- belirli boyutlarına açar
R
birden rank- tensör(R-1)
tensörlerle. AçarN
birlikte bu yonga bu tensörü gelen tensöraxis
boyut,N
, bu tensör en şekilden anlaşılmaktadır. Örneğin, şekli olan bir tensörünün verilen[A, B, C, D]
:- Eğer
axis == 0
sonrai
dönen dizide inci tensör dilimself[i, :, :, :]
ve dizideki her tensör şekle sahip olacaktır[B, C, D]
. (Boyut boyunca çözdükten ki Not gitmiş farklıTensor.split(numSplits:alongAxis)
veyaTensor.split(sizes:alongAxis)
). - Eğer
axis == 1
daha sonrai
dönen dizide inci tensör dilimvalue[:, i, :, :]
ve dizideki her tensör şekle sahip olacaktır[A, C, D]
. - Vesaire.
Bu tersidir
Tensor.init(stacking:alongAxis:)
.ön koşul
axis
aralığında olmalıdır[-rank, rank)
,rank
sağlanır tensörün sıralamasıdır.beyanname
@differentiable public func unstacked(alongAxis axis: Int = 0) -> [Tensor]
parametreler
axis
Yığının kaldırılacağı boyut. Negatif değerler etrafı sarar.
Geri dönüş değeri
Yığınlanmamış tensörleri içeren dizi.
- Eğer
Bir tensörü çoklu tensörlere böler. Tensör boyut boyunca bölünmüş olan
axis
içinecount
küçük tensörlerle. Bu gerektirircount
eşit bölmeshape[axis]
.Örneğin:
// '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]
ön koşul
count
boyutuna boyutu parçalanmalıaxis
eşit.ön koşul
axis
aralığında olmalıdır[-rank, rank)
,rank
sağlanır tensörün sıralamasıdır.beyanname
@differentiable public func split(count: Int, alongAxis axis: Int = 0) -> [Tensor]
parametreler
count
Oluşturulacak bölme sayısı.
axis
Bu tensörün bölüneceği boyut. Negatif değerler etrafı sarar.
Geri dönüş değeri
Tensörler bölümünü içeren bir dizi.
Bir tensörü çoklu tensörlere böler. Tensör ayrılmıştır
sizes.shape[0]
adet. Şeklii
-inci birim boyutu boyunca hariç olmak üzere bu tensörü ile aynı şekle sahipaxis
boyutudursizes[i]
.Örneğin:
// '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]
ön koşul
Değerler
sizes
boyut büyüklüğüne kadar ilave gerekiraxis
.ön koşul
axis
aralığında olmalıdır[-rank, rank)
,rank
sağlanır tensörün sıralamasıdır.beyanname
@differentiable(wrt: self) public func split(sizes: Tensor<Int32>, alongAxis axis: Int = 0) -> [Tensor]
parametreler
sizes
Her bölmenin boyutunu içeren 1-D tensör.
axis
Bu tensörün bölüneceği boyut. Negatif değerler etrafı sarar.
Geri dönüş değeri
Tensör parçalarını içeren dizi.
beyanname
@differentiable(wrt: self) public func split(sizes: [Int], alongAxis axis: Int = 0) -> [Tensor]
Bu tensörün döşenmesiyle oluşturulan kiremitli bir tensör döndürür.
Bu yapıcı Bu tensör kopyalayan yeni tensörünü oluşturur
multiples
kez. İnşa tensör vari
'inci boyuta sahipself.shape[i] * multiples[i]
elemanları ve bu tensör değerleri çoğaltılırmultiples[i]
boyunca kezi
' inci boyut. Örneğin, döşeme[abcd]
ile[2]
üretir[abcdabcd]
.ön koşul
Şeklimultiples
olmalıdır[tensor.rank]
.ön koşul
Tüm skalerlermultiples
olmayan negatif olmalıdır.beyanname
@differentiable(wrt: self) public func tiled(multiples: [Int]) -> Tensor
Bu tensörün döşenmesiyle oluşturulan kiremitli bir tensör döndürür.
Bu yapıcı Bu tensör kopyalayan yeni tensörünü oluşturur
multiples
kez. İnşa tensör vari
'inci boyuta sahipself.shape[i] * multiples[i]
elemanları ve bu tensör değerleri çoğaltılırmultiples[i]
boyunca kezi
' inci boyut. Örneğin, döşeme[abcd]
ile[2]
üretir[abcdabcd]
.ön koşul
Şeklimultiples
olmalıdır[tensor.rank]
.beyanname
@differentiable(wrt: self) public func tiled(multiples: Tensor<Int32>) -> Tensor
Belirtilen şekline yeniden şekillendirme
Tensor
.ön koşul
Skaler sayısı yeni şekle uyuyor.beyanname
@differentiable(wrt: self) public func reshaped<T>(like other: Tensor<T>) -> Tensor where T : TensorFlowScalar
Belirtilen şekle yeniden şekillendirin.
ön koşul
Skaler sayısı yeni şekle uyuyor.beyanname
@differentiable(wrt: self) public func reshaped(to newShape: TensorShape) -> Tensor
Belirtilen için yeniden şekillendirme
Tensor
bir şeklini temsil eden.ön koşul
Skaler sayısı yeni şekle uyuyor.beyanname
@differentiable(wrt: self) public func reshaped(toShape newShape: Tensor<Int32>) -> Tensor
1-D içine çökmüş tensör bir kopyasını döndürür
Tensor
satır-majör sırayla.beyanname
@differentiable(wrt: self) public func flattened() -> Tensor
Şekil genişletilmiş döner
Tensor
belirtilen şekil indeksleri sokulur 1 boyutunda.beyanname
@differentiable(wrt: self) public func expandingShape(at axes: Int...) -> Tensor
Şekil genişletilmiş döner
Tensor
belirtilen şekil indeksleri sokulur 1 boyutunda.beyanname
@differentiable(wrt: self) public func expandingShape(at axes: [Int]) -> Tensor
Bir rütbe-kaldırdı İade
Tensor
1 lider boyutuyla.beyanname
@differentiable(wrt: self) public func rankLifted() -> Tensor
Belirtilen boyut 1 boyutlarını bir tensör şeklinden kaldırır. Boyut belirtilmezse, boyut 1'in tüm boyutları kaldırılacaktır.
beyanname
@differentiable(wrt: self) public func squeezingShape(at axes: Int...) -> Tensor
Belirtilen boyut 1 boyutlarını bir tensör şeklinden kaldırır. Boyut belirtilmezse, boyut 1'in tüm boyutları kaldırılacaktır.
beyanname
@differentiable(wrt: self) public func squeezingShape(at axes: [Int]) -> Tensor
Belirtilen sırada izin verilen boyutlara sahip, transpoze edilmiş bir tensör döndürür.
beyanname
@differentiable(wrt: self) public func transposed(permutation: Tensor<Int32>) -> Tensor
Belirtilen sırada izin verilen boyutlara sahip, transpoze edilmiş bir tensör döndürür.
beyanname
@available(*, deprecated, renamed: "transposed(permutation:﹚") @differentiable(wrt: self) public func transposed(withPermutations permutations: Tensor<Int32>) -> Tensor
Belirtilen sırada izin verilen boyutlara sahip, transpoze edilmiş bir tensör döndürür.
beyanname
@differentiable(wrt: self) public func transposed(permutation: [Int]) -> Tensor
Belirtilen sırada izin verilen boyutlara sahip, yeri değiştirilmiş bir tensör döndürür.
beyanname
@available(*, deprecated, renamed: "transposed(permutation:﹚") @differentiable(wrt: self) public func transposed(withPermutations permutations: [Int]) -> Tensor
Belirtilen sırada izin verilen boyutlara sahip, transpoze edilmiş bir tensör döndürür.
beyanname
@differentiable(wrt: self) public func transposed(permutation: Int...) -> Tensor
Belirtilen sırada izin verilen boyutlara sahip, transpoze edilmiş bir tensör döndürür.
beyanname
@available(*, deprecated, renamed: "transposed(permutation:﹚") @differentiable(wrt: self) public func transposed(withPermutations permutations: Int...) -> Tensor
Boyutları ters sırada izin verilen yer değiştirmiş bir tensör döndürür.
beyanname
@differentiable(wrt: self) public func transposed() -> Tensor
Belirtilen boyutları ters çevrilmiş bir tensör döndürür.
ön koşul
Her bir değeraxes
aralığı içinde olmalıdır-rank..<rank
.ön koşul
Hiçbir çoğaltılması olmalıaxes
.beyanname
@differentiable(wrt: self) public func reversed(inAxes axes: Tensor<Int32>) -> Tensor
Belirtilen boyutları ters çevrilmiş bir tensör döndürür.
ön koşul
Her bir değeraxes
aralığı içinde olmalıdır-rank..<rank
.ön koşul
Hiçbir çoğaltılması olmalıaxes
.beyanname
@differentiable(wrt: self) public func reversed(inAxes axes: [Int]) -> Tensor
Belirtilen boyutları ters çevrilmiş bir tensör döndürür.
ön koşul
Her bir değeraxes
aralığı içinde olmalıdır-rank..<rank
.ön koşul
Hiçbir çoğaltılması olmalıaxes
.beyanname
@differentiable(wrt: self) public func reversed(inAxes axes: Int...) -> Tensor
Belirtilen eksen boyunca birleştirilmiş bir tensör döndürür.
ön koşul
Tensörler, belirtilen eksen dışında aynı boyutlara sahip olmalıdır.ön koşul
Eksen aralığı içinde olmalıdır-rank..<rank
.beyanname
@differentiable public func concatenated(with other: Tensor, alongAxis axis: Int = 0) -> Tensor
Birleştirme operatörü.
Not
++
Swift içinde bulunmayan bir özel operatör olduğunu, ancak Haskell / Scala yapar. Eklenmesi önemsiz bir dil değişikliği değildir ve tartışmalı olabilir. Varlığı / adlandırma++
sonraki bir API tasarım aşamasında tartışılacaktır.beyanname
@differentiable public static func ++ (lhs: Tensor, rhs: Tensor) -> Tensor
De giriş dilimleri bir araya getirerek bir tensörünün döndürür
indices
boyuncaaxis
boyut0-D (skalar) için
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 (vektör) için
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}]
Genel durumda, aşağıdaki durumlarda ortaya çıkan bir tensör üretir:
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}]
burada
N = self.rank
veM = indices.rank
.Elde edilen tensörünün şekli:
self.shape[..<axis] + indices.shape + self.shape[(axis + 1)...]
.Not
CPU'da, aralık dışı bir dizin bulunursa bir hata atılır. GPU'da, aralık dışı bir dizin bulunursa, karşılık gelen çıkış değerlerinde bir 0 saklanır.
ön koşul
axis
aralığında olmalıdır[-rank, rank)
.beyanname
@differentiable(wrt: self) public func gathering<Index: TensorFlowIndex>( atIndices indices: Tensor<Index>, alongAxis axis: Int = 0 ) -> Tensor
parametreler
indices
Toplanacak endeksleri içerir.
axis
Toplanacak boyut. Negatif değerler etrafı sarar.
Geri dönüş değeri
Toplanan tensör.
De döndürür, bu tensörünün dilimleri
indices
boyuncaaxis
boyut, birinci göz ardı ederkenbatchDimensionCount
boyutları bu toplu boyutlarına karşılık gelir. Toplama, toplu olmayan ilk boyut boyunca gerçekleştirilir.Gerçekleştirir benzer işlevsellik
gathering
elde edilen tensör şekli şimdi olması dışında,shape[..<axis] + indices.shape[batchDimensionCount...] + shape[(axis + 1)...]
.ön koşul
axis
aralığında olmalıdır-rank..<rank
da daha büyük olması ya da eşit isebatchDimensionCount
.ön koşul
batchDimensionCount
az olmalıdırindices.rank
.beyanname
@differentiable(wrt: self) public func batchGathering<Index: TensorFlowIndex>( atIndices indices: Tensor<Index>, alongAxis axis: Int = 1, batchDimensionCount: Int = 1 ) -> Tensor
parametreler
indices
Toplanacak endeksleri içerir.
axis
Toplanacak boyut. Negatif değerler etrafı sarar.
batchDimensionCount
Yok sayılacak önde gelen parti boyutlarının sayısı.
Geri dönüş değeri
Toplanan tensör.
Girdiye sağlanan boole maskesini uyguladıktan sonra değerleri toplayarak bir tensör döndürür.
Örneğin:
// 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]]
Genel olarak ise
0 < mask.rank = K <= tensor.rank
vemask
'nin şekli ilk K boyutları eşleşmelidirtensor
s şekli'. Sonra var:tensor.gathering(where: mask)[i, j1, ..., jd] = tensor[i1, ..., iK, j1, ..., jd]
, nereye[i1, ..., iK]
olduğui
incitrue
girişmask
(satır ana düzeni).axis
ile kullanılabilecekmask
gelen maskelemek için eksenini gösterir. Bu durumda,axis + mask.rank <= tensor.rank
vemask
's shape must match the first
eksen + mask.rankdimensions of the
tensor` şekline.ön koşul
mask
: Bir skaler olamazmask.rank != 0
.beyanname
@differentiable(wrt: self) public func gathering(where mask: Tensor<Bool>, alongAxis axis: Int = 0) -> Tensor
parametreler
mask
KD boolean tensör,
K <= self.rank
.axis
İçinde eksenini temsil eden tam sayı tensörü 0-D
self
gelen maskelemek için,K + axis <= self.rank
.Geri dönüş değeri
(self.rank - K + 1)
karşılık gelen bu tensör girişler tarafından doldurulan boyutlu tensörtrue
değerlermask
.Bu tensördeki sıfır olmayan/gerçek değerlerin konumlarını döndürür.
Koordinatlar, ilk boyutun (satırlar) sıfır olmayan öğelerin sayısını temsil ettiği ve ikinci boyutun (sütunlar) sıfır olmayan öğelerin koordinatlarını temsil ettiği 2 boyutlu bir tensörde döndürülür. Çıkış tensörünün şeklinin, bu tensörde kaç tane gerçek değer olduğuna bağlı olarak değişebileceğini unutmayın. Endeksler büyük satır sırasına göre çıktılanır.
Örneğin:
// '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]]
beyanname
public func nonZeroIndices() -> Tensor<Int64>
Geri dönüş değeri
Bir şekle sahip bir tensör
(num_true, rank(condition))
.beyanname
@differentiable(wrt: self) public func broadcasted(toShape shape: Tensor<Int32>) -> Tensor
beyanname
@differentiable(wrt: self) public func broadcasted(to shape: TensorShape) -> Tensor
Belirtilen aynı şekle Yayın
Tensor
.ön koşul
Belirtilen şekil yayın için uyumlu olmalıdır.beyanname
@differentiable(wrt: self) public func broadcasted<OtherScalar>(like other: Tensor<OtherScalar>) -> Tensor where OtherScalar : TensorFlowScalar
beyanname
public static func .= (lhs: inout Tensor, rhs: Tensor)
Her boyut için alt ve üst sınırlarla tanımlanan tensörden bir dilim çıkarır.
beyanname
@differentiable(wrt: self) public func slice(lowerBounds: [Int], upperBounds: [Int]) -> Tensor
parametreler
lowerBounds
Her boyuttaki alt sınırlar.
upperBounds
Her boyutta üst sınırlar.
beyanname
@differentiable(wrt: self) public func slice(lowerBounds: Tensor<Int32>, sizes: Tensor<Int32>) -> Tensor
beyanname
@differentiable(wrt: self) public func slice(lowerBounds: [Int], sizes: [Int]) -> Tensor
beyanname
@differentiable(wrt: self) public subscript(ranges: TensorRangeExpression...) -> Tensor { get set }
Her bir elemanının kontrol eder
axes
bir ekseni belirtirself
ve başka türlü bir teşhis ile programı durdurur.beyanname
func ensureValid( axes: Tensor<Int32>, function: StaticString = #function, file: StaticString = #file, line: UInt = #line )
Her bir elemanının kontrol eder
axes
bir ekseni belirtirself
ve başka türlü bir teşhis ile programı durdurur.beyanname
func ensureValid( axes: [Int], function: StaticString = #function, file: StaticString = #file, line: UInt = #line )
Çekler bu
k
eksenini gösterirself
, aksi takdirde bir teşhis ile program durur.beyanname
func ensureValid( axis k: Int, function: StaticString = #function, file: StaticString = #file, line: UInt = #line )
beyanname
public init<BatchSamples: Collection>(collating samples: BatchSamples) where BatchSamples.Element == Self
Belirtilen şekle ve tekrarlanan tek bir skaler değere sahip bir tensör oluşturur.
beyanname
@available(*, deprecated, renamed: "init(repeating:shape:﹚") public init(shape: TensorShape, repeating repeatedValue: Scalar)
parametreler
shape
Tensörün boyutları.
repeatedValue
Tekrarlanacak skaler değer.
Belirtilen şekle ve tekrarlanan tek bir skaler değere sahip bir tensör oluşturur.
beyanname
@differentiable public init( repeating repeatedValue: Scalar, shape: TensorShape, on device: Device = .default )
parametreler
repeatedValue
Tekrarlanacak skaler değer.
shape
Tensörün boyutları.
Verilen skaleri tüm boyutlar 1 olacak şekilde belirli bir sıraya yayınlayarak bir tensör oluşturur.
beyanname
public init(broadcasting scalar: Scalar, rank: Int, on device: Device = .default)
Bir dizi tensörden (kendileri skaler olabilir) bir tensör oluşturur.
beyanname
@differentiable public init(_ elements: [Tensor])
Yığınlar
tensors
boyunca,axis
cari tensör ve her tensör daha yüksek rütbe biri ile yeni bir tensör içine boyutatensors
.Verilen
tensors
her şekle sahip[A, B, C]
vetensors.count = N
, sonra:- Eğer
axis == 0
sonra elde edilen tensör şekle sahip olacaktır[N, A, B, C]
. - Eğer
axis == 1
daha sonra elde edilen tensör şekle sahip olacaktır[A, N, B, C]
. - vesaire.
Örneğin:
// '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]]
Bu tersidir
Tensor.unstacked(alongAxis:)
.ön koşul
Tüm tensörler aynı şekle sahip olmalıdır.
ön koşul
axis
aralığında olmalıdır[-rank, rank)
,rank
sağlanır tensörün sıralamasıdır.beyanname
@differentiable public init(stacking tensors: [Tensor], alongAxis axis: Int = 0)
parametreler
tensors
Yığınlanacak tensörler.
axis
İstiflenecek boyut. Negatif değerler etrafı sarar.
Geri dönüş değeri
Yığılmış tensör.
- Eğer
Birleştirir
tensors
boyuncaaxis
boyut.Verilen
tensors[i].shape = [D0, D1, ... Daxis(i), ...Dn]
, daha sonra birleştirilmiş sonucu olan şekil[D0, D1, ... Raxis, ...Dn]
, buradaRaxis = sum(Daxis(i))
. Kendisine, giriş tensörlerin veri boyunca birleştiriliraxis
boyut.Örneğin:
// 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]
Not
Kullandığınız düşünün yeni eksen boyunca birleştirerek ise
Tensor.init(stacking:alongAxis:)
.ön koşul
Tüm tansörler aynı dereceye sahip olmalı ve dışındaki tüm boyutlar
axis
eşit olmalıdır.ön koşul
axis
aralığında olmalıdır[-rank, rank)
,rank
sağlanır tensörün sıralamasıdır.beyanname
@differentiable public init(concatenating tensors: [Tensor], alongAxis axis: Int = 0)
parametreler
tensors
Birleştirilecek tensörler.
axis
Birleştirilecek boyut. Negatif değerler etrafı sarar.
Geri dönüş değeri
Birleştirilmiş tensör.
Bu tensör elemanlarını
other
şeritlerdemask
olduğutrue
.ön koşul
self
veother
zorunluluk aynı şekle sahip. Eğerself
veother
sayıl, o zamanmask
ayrıca skaler olmalıdır. Eğerself
veother
daha seviye daha büyük olması ya da eşit1
, daha sonramask
ya olmalıdır ile aynı şekle sahipself
veya bir 1-D,Tensor
şekildemask.scalarCount == self.shape[0]
.beyanname
@differentiable(wrt: (self, other) ) public func replacing(with other: Tensor, where mask: Tensor<Bool>) -> Tensor
Fiziksel skaler tür azaltılmış hassasiyetse true döndürür.
Şu anda, azaltılmış hassasiyet fiziksel sayısal tipleri yalnızca dahil
BFloat16
.beyanname
public var isReducedPrecision: Bool { get }
Verilen tensörle aynı cihaza ve hassasiyete sahip bir skaleri bir tensöre terfi eder.
beyanname
@differentiable public init(_ value: Scalar, deviceAndPrecisionLike tensor: Tensor)
İade bir kopyası
self
dönüştürülenBFloat16
fiziksel skaler tipi.beyanname
public var toReducedPrecision: `Self` { get }
İade bir kopyası
self
dönüştürülürScalar
fiziksel skaler tipi.beyanname
public var toFullPrecision: `Self` { get }
Boyutlarının sayı
Tensor
.beyanname
public var rank: Int { get }
Şekli
Tensor
.beyanname
public var shape: TensorShape { get }
Skaler sayısı
Tensor
.beyanname
public var scalarCount: Int { get }
Bir olarak temsil tensör sıralaması,
Tensor<Int32>
.beyanname
public var rankTensor: Tensor<Int32> { get }
Bir olarak temsil tensör boyutları,
Tensor<Int32>
.beyanname
public var shapeTensor: Tensor<Int32> { get }
Bir olarak temsil tensör skaler sayısı
Tensor<Int32>
.beyanname
public var scalarCountTensor: Tensor<Int32> { get }
İade
true
iserank
0 ve eşittirfalse
aksi.beyanname
public var isScalar: Bool { get }
İade tek skaler öğesi ise
rank
0 ve eşittirnil
aksi.beyanname
public var scalar: Scalar? { get }
Skalere göre yeniden şekillendirin.
ön koşul
Tensörün tam olarak bir skaleri vardır.beyanname
@differentiable public func scalarized() -> Scalar
beyanname
public var array: ShapedArray<Scalar> { get }
beyanname
@differentiable public var scalars: [Scalar] { get }
Skaler bir değerden 0-D tensör oluşturur.
beyanname
@differentiable public init(_ value: Scalar, on device: Device = .default)
Skalerden 1B tensör oluşturur.
beyanname
@differentiable public init(_ scalars: [Scalar], on device: Device = .default)
Skalerden 1B tensör oluşturur.
beyanname
public init<C: Collection>( _ vector: C, on device: Device = .default ) where C.Element == Scalar
Ana satır sırasına göre belirtilen şekle ve bitişik skalerlere sahip bir tensör oluşturur.
ön koşul
Şeklin boyutlarının çarpımı skaler sayısına eşit olmalıdır.beyanname
@differentiable public init(shape: TensorShape, scalars: [Scalar], on device: Device = .default)
parametreler
shape
Tensörün şekli.
scalars
Tensörün skaler içeriği.
Ana satır sırasına göre belirtilen şekle ve bitişik skalerlere sahip bir tensör oluşturur.
ön koşul
Şeklin boyutlarının çarpımı skaler sayısına eşit olmalıdır.beyanname
public init( shape: TensorShape, scalars: UnsafeBufferPointer<Scalar>, on device: Device = .default )
parametreler
shape
Tensörün şekli.
scalars
Tensörün skaler içeriği.
Ana satır sırasına göre belirtilen şekle ve bitişik skalerlere sahip bir tensör oluşturur.
ön koşul
Şeklin boyutlarının çarpımı skaler sayısına eşit olmalıdır.Ana satır sırasına göre belirtilen şekle ve bitişik skalerlere sahip bir tensör oluşturur.
ön koşul
Şeklin boyutlarının çarpımı skaler sayısına eşit olmalıdır.beyanname
public init<C: Collection>( shape: TensorShape, scalars: C, on device: Device = .default ) where C.Element == Scalar
parametreler
shape
Tensörün şekli.
scalars
Tensörün skaler içeriği.
Bir dizi değişmezinin öğelerinin türü.
beyanname
public typealias ArrayLiteralElement = _TensorElementLiteral<Scalar>
Verilen öğelerle başlatılan bir tensör oluşturur.
beyanname
public init(arrayLiteral elements: _TensorElementLiteral<Scalar>...)
Tensörün metinsel bir temsili.
Not
KullanımfullDescription
tüm skalarlar gösteren olmayan hoş yazılı açıklaması.beyanname
public var description: String { get }
Tensörün metinsel bir temsili. Eğer bir özetlenebilir açıklama döndürür
summarize
doğrudur ve eleman sayısı iki kat aşıyoredgeElementCount
.beyanname
public func description( lineWidth: Int = 80, edgeElementCount: Int = 3, summarizing: Bool = false ) -> String
parametreler
lineWidth
Baskı için maksimum çizgi genişliği. Satır başına yazdırılacak skaler sayısını belirlemek için kullanılır.
edgeElementCount
Elemanların sayısı (üç nokta üzerinden önce ve sonra özetleme yazdırmak için
...
).summarizing
Eğer doğruysa eleman sayısı iki kat aşarsa, açıklama özetlemek
edgeElementCount
.Tüm skalerleri gösteren, tensörün tam, hoş yazdırılmamış metinsel gösterimi.
beyanname
public var fullDescription: String { get }
beyanname
public var playgroundDescription: Any { get }
beyanname
public var customMirror: Mirror { get }
Bu tensörü açıklayan açıklamalar.
beyanname
public var annotations: String { get }
Ek açıklamalar için bir takma ad.
beyanname
public var summary: String { get }
beyanname
public init(_owning tensorHandles: UnsafePointer<CTensorHandle>?)
beyanname
public init<C: RandomAccessCollection>( _handles: C ) where C.Element: _AnyTensorHandle
beyanname
public init(_ array: ShapedArray<Scalar>, on device: Device = .default)
beyanname
init(_xla: XLATensor)
beyanname
init(_xlaHandle: UnsafeMutablePointer<OpaqueXLATensor>)
beyanname
var xlaHandle: UnsafeMutablePointer<OpaqueXLATensor> { get }
beyanname
var xlaTensor: XLATensor { get }
beyanname
@differentiable(wrt: self) public func unbroadcasted(toShape otherShape: Tensor<Int32>) -> Tensor
beyanname
@differentiable(wrt: self) public func unbroadcasted<OtherScalar>(like other: Tensor<OtherScalar>) -> Tensor where OtherScalar : TensorFlowScalar
beyanname
@differentiable(wrt: self) public func unbroadcasted(to shape: TensorShape) -> Tensor
Bir tensörün nasıl doldurulacağını belirleyen bir mod.
beyanname
public enum PaddingMode
Belirtilen dolgu boyutlarına göre sabitle doldurulmuş bir tensör döndürür.
beyanname
@differentiable(wrt: self) public func padded(forSizes sizes: [(before: Int, after: Int)], with value: Scalar = 0) -> Tensor
Belirtilen dolgu boyutlarına ve moduna göre dolgulu bir tensör döndürür.
beyanname
@differentiable(wrt: self) public func padded(forSizes sizes: [(before: Int, after: Int)], mode: PaddingMode) -> Tensor
İade hesaplayarak Boole skalerler bir tensör
lhs < rhs
öğeye göre.beyanname
public static func .< (lhs: Tensor, rhs: Tensor) -> Tensor<Bool>
İade hesaplayarak Boole skalerler bir tensör
lhs <= rhs
öğeye göre.beyanname
public static func .<= (lhs: Tensor, rhs: Tensor) -> Tensor<Bool>
İade hesaplayarak Boole skalerler bir tensör
lhs > rhs
öğeye göre.beyanname
public static func .> (lhs: Tensor, rhs: Tensor) -> Tensor<Bool>
Hesaplayarak İade Boole skalerler bir tensörünü
lhs >= rhs
öğeye göre.beyanname
public static func .>= (lhs: Tensor, rhs: Tensor) -> Tensor<Bool>
İade hesaplayarak Boole skalerler bir tensör
lhs < rhs
öğeye göre.Not
.<
Destekler yayın.beyanname
public static func .< (lhs: Scalar, rhs: Tensor) -> Tensor<Bool>
İade hesaplayarak Boole skalerler bir tensör
lhs <= rhs
öğeye göre.Not
.<=
Destekler yayın.beyanname
public static func .<= (lhs: Scalar, rhs: Tensor) -> Tensor<Bool>
İade hesaplayarak Boole skalerler bir tensör
lhs > rhs
öğeye göre.Not
.>
Yayın destekler.beyanname
public static func .> (lhs: Scalar, rhs: Tensor) -> Tensor<Bool>
Hesaplayarak İade Boole skalerler bir tensörünü
lhs >= rhs
öğeye göre.Not
.>=
Yayın destekler.beyanname
public static func .>= (lhs: Scalar, rhs: Tensor) -> Tensor<Bool>
İade hesaplayarak Boole skalerler bir tensör
lhs < rhs
öğeye göre.Not
.<
Destekler yayın.beyanname
public static func .< (lhs: Tensor, rhs: Scalar) -> Tensor<Bool>
İade hesaplayarak Boole skalerler bir tensör
lhs <= rhs
öğeye göre.Not
.<=
Destekler yayın.beyanname
public static func .<= (lhs: Tensor, rhs: Scalar) -> Tensor<Bool>
İade hesaplayarak Boole skalerler bir tensör
lhs > rhs
öğeye göre.Not
.>
Yayın destekler.beyanname
public static func .> (lhs: Tensor, rhs: Scalar) -> Tensor<Bool>
Hesaplayarak İade Boole skalerler bir tensörünü
lhs >= rhs
öğeye göre.Not
.>=
Yayın destekler.beyanname
public static func .>= (lhs: Tensor, rhs: Scalar) -> Tensor<Bool>
İade hesaplayarak Boole skalerler bir tensör
lhs == rhs
öğeye göre.Not
.==
destekler yayın.beyanname
public static func .== (lhs: Tensor, rhs: Tensor) -> Tensor<Bool>
İade hesaplayarak Boole skalerler bir tensör
lhs != rhs
öğeye göre.Not
.!=
Destekler yayın.beyanname
public static func .!= (lhs: Tensor, rhs: Tensor) -> Tensor<Bool>
İade hesaplayarak Boole skalerler bir tensör
lhs == rhs
öğeye göre.Not
.==
destekler yayın.beyanname
public static func .== (lhs: Scalar, rhs: Tensor) -> Tensor<Bool>
İade hesaplayarak Boole skalerler bir tensör
lhs != rhs
öğeye göre.Not
.!=
Destekler yayın.beyanname
public static func .!= (lhs: Scalar, rhs: Tensor) -> Tensor<Bool>
İade hesaplayarak Boole skalerler bir tensör
lhs == rhs
öğeye göre.Not
.==
destekler yayın.beyanname
public static func .== (lhs: Tensor, rhs: Scalar) -> Tensor<Bool>
İade hesaplayarak Boole skalerler bir tensör
lhs != rhs
öğeye göre.Not
.!=
Destekler yayın.beyanname
public static func .!= (lhs: Tensor, rhs: Scalar) -> Tensor<Bool>
İade elemanları olmadığını gösteren Boole değerlerinin bir tensör
self
olanların yaklaşık olarak eşit olanother
.ön koşul
self
veother
zorunluluk aynı şekilde olması.beyanname
public func elementsAlmostEqual( _ other: Tensor, tolerance: Scalar = Scalar.ulpOfOne.squareRoot() ) -> Tensor<Bool>
İade
true
tüm unsurları eğerself
olanların yaklaşık olarak eşit olanother
.ön koşul
self
veother
zorunluluk aynı şekilde olması.beyanname
public func isAlmostEqual( to other: Tensor, tolerance: Scalar = Scalar.ulpOfOne.squareRoot() ) -> Bool
Bu tensör için bir çapraz çoğaltma toplamı çalıştırır. Aynı çapraz çoğaltma toplamı, toplama katılan diğer cihazların her birinde gerçekleşmelidir.
beyanname
public mutating mutating func crossReplicaSum(_ scale: Double)
beyanname
@derivative init(repeating: shape)
Bir başka bir öğeye göre tip dönüştürme işlemini
Bool
tensörü.beyanname
public init(_ other: Tensor<Bool>)
Başka bir öğeye göre dönüştürme gerçekleştirmek
Tensor
.beyanname
@differentiable public init<OtherScalar>(_ other: Tensor<OtherScalar>) where OtherScalar : Numeric, OtherScalar : TensorFlowScalar
beyanname
@derivative init(_: <<error type>>)
beyanname
@derivative init(stacking: alongAxis)
beyanname
@derivative init(concatenating: alongAxis)
Tüm skaler değerleri sıfıra ayarlanmış bir tensör oluşturur.
beyanname
public init(zeros shape: TensorShape, on device: Device = .default)
parametreler
shape
Tensörün şekli.
Tüm skaler değerleri bire ayarlanmış bir tensör oluşturur.
beyanname
public init(ones shape: TensorShape, on device: Device = .default)
parametreler
shape
Tensörün şekli.
Sağlanan tensörle aynı şekle ve türe sahip, tüm skalerleri sıfıra ayarlanmış bir tensör oluşturur.
beyanname
public init(zerosLike other: Tensor)
parametreler
other
Şekli ve veri türü kullanılacak tensör.
Sağlanan tensörle aynı şekle ve türe sahip olana tüm skalerleri ayarlanmış bir tensör oluşturur.
beyanname
public init(onesLike other: Tensor)
parametreler
other
Şekli ve veri türü kullanılacak tensör.
Bir başlangıç değerinden bir bitiş değerine kadar, ancak bunu içermeyen, belirtilen miktarda adım adım bir diziyi temsil eden bir 1-D tensör oluşturur.
beyanname
public init( rangeFrom start: Scalar, to end: Scalar, stride: Scalar, on device: Device = .default )
parametreler
start
Dizi için kullanılacak başlangıç değeri. Sekansı, herhangi bir değer içeriyorsa, ilki
start
.end
Diziyi sınırlamak için bir bitiş değeri.
end
elde edilen dizinin bir elemanı olmadı.stride
Her yinelemede adım atılacak miktar.
stride
pozitif olmalıdır.Bir başlangıç değerinden bir bitiş değerine kadar, ancak bunu içermeyen, belirtilen miktarda adım adım bir diziyi temsil eden bir 1-D tensör oluşturur.
beyanname
public init(rangeFrom start: Tensor<Scalar>, to end: Tensor<Scalar>, stride: Tensor<Scalar>)
parametreler
start
Dizi için kullanılacak başlangıç değeri. Sekansı, herhangi bir değer içeriyorsa, ilki
start
.end
Diziyi sınırlamak için bir bitiş değeri.
end
elde edilen dizinin bir elemanı olmadı.stride
Her yinelemede adım atılacak miktar.
stride
pozitif olmalıdır.Verilen indekslerde bir sıcak tensör oluşturur. İle temsil edilen konumlar
indices
değeri alıronValue
(1
tüm diğer konumlar değer alırken, varsayılan)offValue
(0
varsayılan). Giriş Eğerindices
sıralaması ne kadarn
, yeni tensör dereceye sahip olacaktırn+1
. Yeni eksen boyut oluşturuluraxis
(varsayılan olarak, yeni eksen sonuna eklenir).Eğer
indices
bir skaler olduğunu, yeni tensör şekli uzunluğu bir vektör olacakdepth
.Eğer
indices
uzunlukta bir vektördürfeatures
, çıktı şekli olacaktır: özellikler x derinlik, eğer eksen == -1 derinlik x özellikleri, eksen == 0 iseEğer
indices
şekli ile bir matris (yığın) olan[batch, features]
, çıktı şekli olacaktır: kesikli x x derinliği özellikleri ise eksen == -1 toplu x derinlik x özellikleri, ekseni == 1 derinlik x yığın x özellikler ise , eğer eksen == 0beyanname
public init( oneHotAtIndices indices: Tensor<Int32>, depth: Int, onValue: Scalar = 1, offValue: Scalar = 0, axis: Int = -1 )
parametreler
indices
Bir
Tensor
endeksleri.depth
Bir sıcak boyutun derinliğini tanımlayan bir skaler.
onValue
Yerde değerini tanımlayan bir skaler bazı dizine göre anılan
indices
.offValue
Herhangi dizine göre adlandırılan olmayan bir yerde değer tanımlayan bir sayıl
indices
.axis
Doldurulacak eksen. Varsayılan
-1
, yeni bir en iç ekseni.
Belirtilen değerlerin sayısını oluşturmak için eşit aralıklarla yerleştirilmiş, bir başlangıç değerinden bitiş değerine kadar ve bu değer dahil bir diziyi temsil eden bir 1-D tensör oluşturur.
beyanname
public init( linearSpaceFrom start: Scalar, to end: Scalar, count: Int, on device: Device = .default )
parametreler
start
Dizi için kullanılacak başlangıç değeri. Sekansı, herhangi bir değer içeriyorsa, ilki
start
.end
Diziyi sınırlamak için bir bitiş değeri.
end
elde edilen dizinin son elemanıdır.count
Sonuç dizisindeki değerlerin sayısı.
count
pozitif olmalıdır.Belirtilen değerlerin sayısını oluşturmak için eşit aralıklarla yerleştirilmiş, bir başlangıç değerinden bitiş değerine kadar ve bu değer dahil bir diziyi temsil eden bir 1-D tensör oluşturur.
ön koşul
start
,to
, vecount
tek Skaler değeri içeren Tensörleri olmalıdır.beyanname
public init(linearSpaceFrom start: Tensor<Scalar>, to end: Tensor<Scalar>, count: Tensor<Int32>)
parametreler
start
Dizi için kullanılacak başlangıç değeri. Sekansı, herhangi bir değer içeriyorsa, ilki
start
.end
Diziyi sınırlamak için bir bitiş değeri.
end
elde edilen dizinin son elemanıdır.count
Sonuç dizisindeki değerlerin sayısı.
count
pozitif olmalıdır.
Rasgele arasında tek bir şekilde dağılımı ile ilgili sayısal değerler, örnekleme özel bir şekle sahip bir tensörünün oluşturur
lowerBound
veupperBound
.beyanname
public init( randomUniform shape: TensorShape, lowerBound: Tensor<Scalar>? = nil, upperBound: Tensor<Scalar>? = nil, seed: TensorFlowSeed = Context.local.randomSeed, on device: Device = .default )
parametreler
shape
Tensörün boyutları.
lowerBound
Dağıtımın alt sınırı.
upperBound
Dağılımın üst sınırı.
seed
Tohum değeri.
Rasgele arasında tek bir şekilde dağılımı ile ilgili sayısal değerler, örnekleme özel bir şekle sahip bir tensörünün oluşturur
lowerBound
veupperBound
.beyanname
public init( randomUniform shape: TensorShape, lowerBound: Tensor<Scalar>? = nil, upperBound: Tensor<Scalar>? = nil, seed: TensorFlowSeed = Context.local.randomSeed, on device: Device = .default )
parametreler
shape
Tensörün boyutları.
lowerBound
Dağıtımın alt sınırı.
upperBound
Dağılımın üst sınırı.
seed
Tohum değeri.
Normal bir dağılımdan skaler değerleri rastgele örnekleyerek belirtilen şekle sahip bir tensör oluşturur.
beyanname
public init( randomNormal shape: TensorShape, mean: Tensor<Scalar>? = nil, standardDeviation: Tensor<Scalar>? = nil, seed: TensorFlowSeed = Context.local.randomSeed, on device: Device = .default )
parametreler
shape
Tensörün boyutları.
mean
Dağılımın ortalaması.
standardDeviation
Dağılımın standart sapması.
seed
Tohum değeri.
Kesilmiş bir Normal dağılımdan skaler değerleri rastgele örnekleyerek belirtilen şekle sahip bir tensör oluşturur.
beyanname
public init( randomTruncatedNormal shape: TensorShape, mean: Tensor<Scalar>? = nil, standardDeviation: Tensor<Scalar>? = nil, seed: TensorFlowSeed = Context.local.randomSeed, on device: Device = .default )
parametreler
shape
Tensörün boyutları.
mean
Dağılımın ortalaması.
standardDeviation
Dağılımın standart sapması.
seed
Tohum değeri.
Kategorik bir dağılımdan örnekler çizerek bir tensör oluşturur.
beyanname
public init<T: TensorFlowFloatingPoint>( randomCategorialLogits: Tensor<T>, sampleCount: Int32, seed: TensorFlowSeed = Context.local.randomSeed )
parametreler
randomCategorialLogits
Şekli ile 2-B tensör
[batchSize, classCount]
. Her bir dilim[i, :]
tüm sınıfları için normalleştirilmemiş günlük olasılıklarını temsil eder.sampleCount
0-D. Her satır dilimi için çizilecek bağımsız örnek sayısı.
seed
Tohum değeri.
Geri dönüş değeri
Şekli ile 2-B tensör
[batchSize, sampleCount]
. Her bir dilim[i, :]
aralığı ile çizilmiş sınıf etiketleri içeren[0, classCount)
.
Glorot (Xavier) tek tip başlatma gerçekleştirerek belirtilen şekle sahip bir tensör oluşturur.
Bu arasında düzgün bir dağıtım rasgele numune çizer
-limit
velimit
varsayılan rasgele sayı üreteci tarafından üretilenlimit
olansqrt(6 / (fanIn + fanOut))
vefanIn
/fanOut
alıcı ile çarpılır özellikleri giriş ve çıkış sayısını temsil eder alan boyutu.Referans: “Derin ileri beslemeli sinir ağları eğitimi zorluğunu anlama”
beyanname
public init( glorotUniform shape: TensorShape, seed: TensorFlowSeed = Context.local.randomSeed, on device: Device = .default )
parametreler
shape
Tensörün boyutları.
seed
Tohum değeri.
Glorot (Xavier) normal başlatma işlemini gerçekleştirerek belirtilen şekle sahip bir tensör oluşturur.
Bu kesik normal dağılımdan rasgele örnekleri merkezli çizer
0
standart sapma ilesqrt(2 / (fanIn + fanOut))
varsayılan rasgele sayı üreteci tarafından üretilenfanIn
/fanOut
giriş ve çıkış sayısını temsil açık alan ile çarpılır özellikleri boy.Referans: “Derin ileri beslemeli sinir ağları eğitimi zorluğunu anlama”
beyanname
public init( glorotNormal shape: TensorShape, seed: TensorFlowSeed = Context.local.randomSeed, on device: Device = .default )
parametreler
shape
Tensörün boyutları.
seed
Tohum değeri.
He (Kaiming) tek biçimli başlatma gerçekleştirerek belirtilen şekle sahip bir tensör oluşturur.
Bu arasında düzgün bir dağıtım rasgele numune çizer
-limit
velimit
varsayılan rasgele sayı üreteci tarafından üretilenlimit
olansqrt(6 / fanIn)
vefanIn
giriş sayısı açık alan büyüklüğüyle çarpılması özellikleri temsil eder.Referans: “Delving'in Derin Redresör içine: ImageNet Sınıflandırma İnsan Düzeyli Performansı aşarak”
beyanname
public init( heUniform shape: TensorShape, seed: TensorFlowSeed = Context.local.randomSeed, on device: Device = .default )
parametreler
shape
Tensörün boyutları.
seed
Tohum değeri.
He (Kaiming) normal başlatma işlemini gerçekleştirerek belirtilen şekle sahip bir tensör oluşturur.
Bu kesik normal dağılımdan rasgele örnekleri merkezli çizer
0
standart sapma ilesqrt(2 / fanIn))
varsayılan rasgele sayı üreteci tarafından üretilenfanIn
giriş sayısı açık alan büyüklüğüyle çarpılması özellikleri temsil eder.Referans: “Delving'in Derin Redresör içine: ImageNet Sınıflandırma İnsan Düzeyli Performansı aşarak”
beyanname
public init( heNormal shape: TensorShape, seed: TensorFlowSeed = Context.local.randomSeed, on device: Device = .default )
parametreler
shape
Tensörün boyutları.
seed
Tohum değeri.
LeCun tek tip başlatma gerçekleştirerek belirtilen şekle sahip bir tensör oluşturur.
Bu arasında düzgün bir dağıtım rasgele numune çizer
-limit
velimit
varsayılan rasgele sayı üreteci tarafından üretilenlimit
olansqrt(3 / fanIn)
vefanIn
giriş sayısı açık alan büyüklüğüyle çarpılması özellikleri temsil eder.Referans: “Verimli BackProp”
beyanname
public init( leCunUniform shape: TensorShape, seed: TensorFlowSeed = Context.local.randomSeed, on device: Device = .default )
parametreler
shape
Tensörün boyutları.
seed
Tohum değeri.
LeCun normal başlatma işlemini gerçekleştirerek belirtilen şekle sahip bir tensör oluşturur.
Bu kesik normal dağılımdan rasgele örnekleri merkezli çizer
0
standart sapma ilesqrt(1 / fanIn)
varsayılan rasgele sayı üreteci tarafından üretilenfanIn
giriş sayısı açık alan büyüklüğüyle çarpılması özellikleri temsil eder.Referans: “Verimli BackProp”
beyanname
public init( leCunNormal shape: TensorShape, seed: TensorFlowSeed = Context.local.randomSeed, on device: Device = .default )
parametreler
shape
Tensörün boyutları.
seed
Tohum değeri.
Ortogonal bir matris veya tensör oluşturur.
Başlatılacak tensörün şekli iki boyutlu ise, normal dağılımdan çizilen rastgele sayılar matrisinin QR ayrıştırmasından elde edilen ortogonal bir matris ile başlatılır. Matrisin sütunlardan daha az satırı varsa, çıktının dikey satırları olacaktır. Aksi takdirde, çıktının ortogonal sütunları olacaktır.
İnitialize tensörünün şekli ise daha iki boyutlu daha şekli bir matris
[shape[0] * ... * shape[rank - 2], shape[rank - 1]]
başlatıldı. Matris daha sonra istenen şekle sahip bir tensör verecek şekilde yeniden şekillendirilir.beyanname
public init( orthogonal shape: TensorShape, gain: Tensor<Scalar> = Tensor<Scalar>(1), seed: TensorFlowSeed = Context.local.randomSeed )
parametreler
shape
Tensörün şekli.
gain
Ortogonal tensöre uygulanacak bir çarpımsal faktör.
seed
Rastgele sayı üretecini tohumlamak için iki tamsayı demeti.
Bir [toplu] tensörün [toplu] köşegen kısmını döndürür. Şeklin tensör Örneğin
[..., M, N]
, çıkış şeklinin bir tensör olan[..., K]
, buradaK
eşittirmin(N, M)
.Örneğin:
// 't' is [[1, 0, 0, 0] // [0, 2, 0, 0] // [0, 0, 3, 0] // [0, 0, 0, 4]] t.diagonalPart() // [1, 2, 3, 4]
beyanname
@differentiable public func diagonalPart() -> Tensor
Bir [toplu] çapraz dizi oluşturur. Şeklin tensör Örneğin
[..., M]
, çıkış şeklinin bir tensör olan[..., M, M]
.Örneğin:
// 't' is [1, 2, 3, 4] t.diagonal() // [[1, 0, 0, 0] // [0, 2, 0, 0] // [0, 0, 3, 0] // [0, 0, 0, 4]]
beyanname
@differentiable public func diagonal() -> Tensor
İade
self
yeni diyagonal değerlerle, yani verilenself
isteğe bağlı olarak Toplu matristir.İade tensör aynı şekil ve değerlerine sahip
self
değerleri tarafından yazılır içteki matrisleri belirtilen çaprazlarda hariç,diagonal
.Diyagonal Parametre: rütbe ile tensör
rank - 1
yeni diyagonal değerleri temsil.beyanname
public func withDiagonal(_ diagonal: Tensor<Scalar>) -> Tensor
beyanname
@differentiable(wrt: self) public func bandPart(_ subdiagonalCount: Int, _ superdiagonalCount: Int) -> Tensor
Merkezi bant sınırları tarafından tanımlanan en içteki tensörün bir kopyasını döndürür. Çıkış örneği ile aynı şekilde bir tensör olan
[..., :, :]
.Örneğin:
// '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]]
beyanname
@differentiable public func bandPart(subdiagonalCount: Int, superdiagonalCount: Int) -> Tensor
parametreler
subdiagonalCount
Tutulacak alt köşegen sayısı. Negatifse, tüm alt üçgeni koruyun.
superdiagonalCount
Tutulacak süper köşegenlerin sayısı. Negatifse, tüm üst üçgeni koruyun.
İade tensörü her iç matrisin QR ayrışımı, iç ortogonal matrisler ile tensör
q
ve iç üst üçgen matrisler ile tensörr
tensör eşittir, öyle kimatmul(q, r)
.beyanname
public func qrDecomposition(fullMatrices: Bool = false) -> ( q: Tensor<Scalar>, r: Tensor<Scalar> )
parametreler
fullMatrices
Eğer
true
, tam boy hesaplamakq
ver
. Aksi takdirde, sadece lider hesaplamakmin(shape[rank - 1], shape[rank - 2])
sütunlarıq
.İade tekil değer ayrışımı
self
göz önüne alındığında,self
isteğe bağlı olarak harmanlanmış bir matristir.İsteğe bağlı olarak harmanlanmış matris tekil değer ayrışımı (SVD)
self
değerindedirs
,u
, vev
, ki burada:self[..., :, :] = u[..., :, :] • s[..., :, :].diagonal() • v[..., :, :].transposed()`
öz
must be a tensor with shape
[..., M, N]. Let
, K = dakika (M, N) '.ön koşul
self
şekli ile bir tensör olmalıdır[..., M, N]
.beyanname
public func svd(computeUV: Bool = true, fullMatrices: Bool = false) -> ( s: Tensor<Scalar>, u: Tensor<Scalar>?, v: Tensor<Scalar>? )
parametreler
computeUV
Eğer
true
, sol ve sağ tekil vektörler hesaplanır ve olarak döndürülüru
vev
sırasıyla. Eğerfalse
,nil
değerler olarak döndürülüru
vev
.fullMatrices
Eğer
true
,u
vev
sırasıyla şekiller var[..., M, M]
ve[..., N, N]
. Eğerfalse
,u
vev
, sırasıyla şekillere sahip[..., M, K]
ve[..., K, N]
. Ne zaman SayılancomputeUV
yanlıştır.Geri dönüş değeri
- s: tekil değerler, şekli ile
[..., K]
. Her vektör içinde tekil değerler azalan düzende sıralanır. - u: Sol tekil vektörler.
- v: Sağ tekil vektörler.
- s: tekil değerler, şekli ile
Karekökü
x
.Eğer gerçek türleri için,
x
negatif sonuçtur.nan
. Karmaşık tipler için negatif reel eksende bir dal kesimi vardır.beyanname
@differentiable public static func sqrt(_ x: `Self`) -> Tensor<Scalar>
Kosinüs
x
radyan cinsinden bir açı olarak yorumlanır.beyanname
@differentiable public static func cos(_ x: `Self`) -> Tensor<Scalar>
Olmazsa
x
radyan cinsinden bir açı olarak yorumlanır.beyanname
@differentiable public static func sin(_ x: `Self`) -> Tensor<Scalar>
Tanjant
x
radyan cinsinden bir açı olarak yorumlanır.beyanname
@differentiable public static func tan(_ x: `Self`) -> Tensor<Scalar>
Ters kosinüs
x
radyan.beyanname
@differentiable public static func acos(_ x: `Self`) -> Tensor<Scalar>
Ters sinüs
x
radyan.beyanname
@differentiable public static func asin(_ x: `Self`) -> Tensor<Scalar>
Ters tanjant
x
radyan.beyanname
@differentiable public static func atan(_ x: `Self`) -> Tensor<Scalar>
Hiperbolik kosinüs
x
.beyanname
@differentiable public static func cosh(_ x: `Self`) -> Tensor<Scalar>
The hyperbolic sine of
x
.beyanname
@differentiable public static func sinh(_ x: `Self`) -> Tensor<Scalar>
The hyperbolic tangent of
x
.beyanname
@differentiable public static func tanh(_ x: `Self`) -> Tensor<Scalar>
The inverse hyperbolic cosine of
x
.beyanname
@differentiable public static func acosh(_ x: `Self`) -> Tensor<Scalar>
The inverse hyperbolic sine of
x
.beyanname
@differentiable public static func asinh(_ x: `Self`) -> Tensor<Scalar>
The inverse hyperbolic tangent of
x
.beyanname
@differentiable public static func atanh(_ x: `Self`) -> Tensor<Scalar>
The exponential function applied to
x
, ore**x
.beyanname
@differentiable public static func exp(_ x: `Self`) -> Tensor<Scalar>
Two raised to to power
x
.beyanname
@differentiable public static func exp2(_ x: `Self`) -> Tensor<Scalar>
Ten raised to to power
x
.beyanname
@differentiable public static func exp10(_ x: `Self`) -> Tensor<Scalar>
exp(x) - 1
evaluated so as to preserve accuracy close to zero.beyanname
@differentiable public static func expm1(_ x: `Self`) -> Tensor<Scalar>
The natural logarithm of
x
.beyanname
@differentiable public static func log(_ x: `Self`) -> Tensor<Scalar>
The base-two logarithm of
x
.beyanname
@differentiable public static func log2(_ x: `Self`) -> Tensor<Scalar>
The base-ten logarithm of
x
.beyanname
@differentiable public static func log10(_ x: `Self`) -> Tensor<Scalar>
log(1 + x)
evaluated so as to preserve accuracy close to zero.beyanname
@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.beyanname
@differentiable public static func pow(_ x: `Self`, _ y: `Self`) -> Tensor<Scalar>
x
raised to then
th power.The product of
n
copies ofx
.beyanname
@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.beyanname
@differentiable public static func root(_ x: `Self`, _ n: Int) -> Tensor<Scalar>
beyanname
public typealias VectorSpaceScalar = Float
beyanname
public func scaled(by scale: Float) -> Tensor<Scalar>
beyanname
public func adding(_ scalar: Float) -> Tensor<Scalar>
beyanname
public func subtracting(_ scalar: Float) -> Tensor<Scalar>
Adds the scalar to every scalar of the tensor and produces the sum.
beyanname
@differentiable public static func + (lhs: Scalar, rhs: Tensor) -> Tensor
Adds the scalar to every scalar of the tensor and produces the sum.
beyanname
@differentiable public static func + (lhs: Tensor, rhs: Scalar) -> Tensor
Subtracts the scalar from every scalar of the tensor and produces the difference.
beyanname
@differentiable public static func - (lhs: Scalar, rhs: Tensor) -> Tensor
Subtracts the scalar from every scalar of the tensor and produces the difference
beyanname
@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.beyanname
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.
beyanname
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.beyanname
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.
beyanname
public static func -= (lhs: inout Tensor, rhs: Scalar)
Returns the tensor produced by multiplying the two tensors.
Note
*
supports broadcasting.beyanname
@differentiable public static func * (lhs: Tensor, rhs: Tensor) -> Tensor
Returns the tensor by multiplying it with every scalar of the tensor.
beyanname
@differentiable public static func * (lhs: Scalar, rhs: Tensor) -> Tensor
Multiplies the scalar with every scalar of the tensor and produces the product.
beyanname
@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.beyanname
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.
beyanname
public static func *= (lhs: inout Tensor, rhs: Scalar)
Returns the quotient of dividing the first tensor by the second.
Note
/
supports broadcasting.beyanname
@differentiable public static func / (lhs: Tensor, rhs: Tensor) -> Tensor
Returns the quotient of dividing the scalar by the tensor, broadcasting the scalar.
beyanname
@differentiable public static func / (lhs: Scalar, rhs: Tensor) -> Tensor
Returns the quotient of dividing the tensor by the scalar, broadcasting the scalar.
beyanname
@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.
beyanname
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.
beyanname
public static func /= (lhs: inout Tensor, rhs: Scalar)
Returns the remainder of dividing the first tensor by the second.
Note
%
supports broadcasting.beyanname
public static func % (lhs: Tensor, rhs: Tensor) -> Tensor
Returns the remainder of dividing the tensor by the scalar, broadcasting the scalar.
beyanname
public static func % (lhs: Tensor, rhs: Scalar) -> Tensor
Returns the remainder of dividing the scalar by the tensor, broadcasting the scalar.
beyanname
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.
beyanname
public static func %= (lhs: inout Tensor, rhs: Tensor)
Divides the tensor by the scalar and stores the remainder in the left-hand-side variable.
beyanname
public static func %= (lhs: inout Tensor, rhs: Scalar)
Returns
!self
element-wise.beyanname
public func elementsLogicalNot() -> Tensor
Returns
self && other
element-wise.Note
&&
supports broadcasting.beyanname
public func elementsLogicalAnd(_ other: Tensor) -> Tensor
Returns
self && other
element-wise, broadcastingother
.beyanname
public func elementsLogicalAnd(_ other: Scalar) -> Tensor
Returns
self || other
element-wise.beyanname
public func elementsLogicalOr(_ other: Tensor) -> Tensor
Returns
self || other
element-wise, broadcastingother
.beyanname
public func elementsLogicalOr(_ other: Scalar) -> Tensor
Returns
max(min(self, max), min)
.beyanname
@differentiable public func clipped(min: Tensor, max: Tensor) -> Tensor
Returns
max(min(self, max), min)
.beyanname
@differentiable(wrt: (self, min) ) public func clipped(min: Tensor, max: Scalar) -> Tensor
Returns
max(min(self, max), min)
.beyanname
@differentiable(wrt: (self, max) ) public func clipped(min: Scalar, max: Tensor) -> Tensor
Returns
max(min(self, max), min)
.beyanname
@differentiable(wrt: self) public func clipped(min: Scalar, max: Scalar) -> Tensor
Returns the negation of the specified tensor element-wise.
beyanname
@differentiable public prefix static func - (rhs: Tensor) -> Tensor
beyanname
@differentiable(wrt: self) public func squared() -> Tensor
Returns a boolean tensor indicating which elements of
x
are finite.beyanname
public var isFinite: Tensor<Bool> { get }
Returns a boolean tensor indicating which elements of
x
are infinite.beyanname
public var isInfinite: Tensor<Bool> { get }
Returns a boolean tensor indicating which elements of
x
are NaN-valued.beyanname
public var isNaN: Tensor<Bool> { get }
Returns
true
if all scalars are equal totrue
. Otherwise, returnsfalse
.beyanname
public func all() -> Bool
Returns
true
if any scalars are equal totrue
. Otherwise, returnsfalse
.beyanname
public func any() -> Bool
Performs a logical AND operation along the specified axes. The reduced dimensions are removed.
ön koşul
Each value inaxes
must be in the range-rank..<rank
.beyanname
public func all(squeezingAxes axes: Int...) -> Tensor
parametreler
axes
The dimensions to reduce.
Performs a logical AND operation along the specified axes. The reduced dimensions are removed.
ön koşul
Each value inaxes
must be in the range-rank..<rank
.beyanname
public func any(squeezingAxes axes: Int...) -> Tensor
parametreler
axes
The dimensions to reduce.
Performs a logical AND operation along the specified axes. The reduced dimensions are retained with value 1.
ön koşul
Each value inaxes
must be in the range-rank..<rank
.beyanname
public func all(alongAxes axes: Int...) -> Tensor
parametreler
axes
The dimensions to reduce.
Performs a logical OR operation along the specified axes. The reduced dimensions are retained with value 1.
ön koşul
Each value inaxes
must be in the range-rank..<rank
.beyanname
public func any(alongAxes axes: Int...) -> Tensor
parametreler
axes
The dimensions to reduce.
beyanname
@differentiable public func min() -> Tensor
beyanname
@differentiable public func max() -> Tensor
Returns the maximum values along the specified axes. The reduced dimensions are removed.
ön koşul
Each value inaxes
must be in the range-rank..<rank
.beyanname
@differentiable(wrt: self) public func max(squeezingAxes axes: Tensor<Int32>) -> Tensor
parametreler
axes
The dimensions to reduce.
Returns the maximum values along the specified axes. The reduced dimensions are removed.
ön koşul
Each value inaxes
must be in the range-rank..<rank
.beyanname
@differentiable(wrt: self) public func max(squeezingAxes axes: [Int]) -> Tensor
parametreler
axes
The dimensions to reduce.
Returns the maximum values along the specified axes. The reduced dimensions are removed.
ön koşul
Each value inaxes
must be in the range-rank..<rank
.beyanname
@differentiable(wrt: self) public func max(squeezingAxes axes: Int...) -> Tensor
parametreler
axes
The dimensions to reduce.
Returns the minimum values along the specified axes. The reduced dimensions are removed.
ön koşul
Each value inaxes
must be in the range-rank..<rank
.beyanname
@differentiable(wrt: self) public func min(squeezingAxes axes: Tensor<Int32>) -> Tensor
parametreler
axes
The dimensions to reduce.
Returns the minimum values along the specified axes. The reduced dimensions are removed.
ön koşul
Each value inaxes
must be in the range-rank..<rank
.beyanname
@differentiable(wrt: self) public func min(squeezingAxes axes: [Int]) -> Tensor
parametreler
axes
The dimensions to reduce.
Returns the minimum values along the specified axes. The reduced dimensions are removed.
ön koşul
Each value inaxes
must be in the range-rank..<rank
.beyanname
@differentiable(wrt: self) public func min(squeezingAxes axes: Int...) -> Tensor
parametreler
axes
The dimensions to reduce.
Returns the indices of the maximum values along the specified axes. The reduced dimensions are removed.
ön koşul
Each value inaxes
must be in the range-rank..<rank
.beyanname
public func argmax(squeezingAxis axis: Int) -> Tensor<Int32>
parametreler
axes
The dimensions to reduce.
Returns the indices of the minimum values along the specified axes. The reduced dimensions are removed.
ön koşul
Each value inaxes
must be in the range-rank..<rank
.beyanname
public func argmin(squeezingAxis axis: Int) -> Tensor<Int32>
parametreler
axes
The dimensions to reduce.
Returns the minimum along the specified axes. The reduced dimensions are retained with value 1.
ön koşul
Each value inaxes
must be in the range-rank..<rank
.beyanname
@differentiable(wrt: self) public func min(alongAxes axes: Tensor<Int32>) -> Tensor
parametreler
axes
The dimensions to reduce.
Returns the minimum along the specified axes. The reduced dimensions are retained with value 1.
ön koşul
Each value inaxes
must be in the range-rank..<rank
.beyanname
@differentiable(wrt: self) public func min(alongAxes axes: [Int]) -> Tensor
parametreler
axes
The dimensions to reduce.
Returns the minimum along the specified axes. The reduced dimensions are retained with value 1.
ön koşul
Each value inaxes
must be in the range-rank..<rank
.beyanname
@differentiable(wrt: self) public func min(alongAxes axes: Int...) -> Tensor
parametreler
axes
The dimensions to reduce.
Returns the minimum along the specified axes. The reduced dimensions are retained with value 1.
ön koşul
Each value inaxes
must be in the range-rank..<rank
.beyanname
@differentiable(wrt: self) public func max(alongAxes axes: Tensor<Int32>) -> Tensor
parametreler
axes
The dimensions to reduce.
Returns the minimum along the specified axes. The reduced dimensions are retained with value 1.
ön koşul
Each value inaxes
must be in the range-rank..<rank
.beyanname
@differentiable(wrt: self) public func max(alongAxes axes: [Int]) -> Tensor
parametreler
axes
The dimensions to reduce.
Returns the minimum along the specified axes. The reduced dimensions are retained with value 1.
ön koşul
Each value inaxes
must be in the range-rank..<rank
.beyanname
@differentiable(wrt: self) public func max(alongAxes axes: Int...) -> Tensor
parametreler
axes
The dimensions to reduce.
Returns the index of the maximum value of the flattened scalars.
beyanname
public func argmax() -> Tensor<Int32>
Returns the index of the minimum value of the flattened scalars.
beyanname
public func argmin() -> Tensor<Int32>
Returns the sum along the specified axes. The reduced dimensions are removed.
ön koşul
Each value inaxes
must be in the range-rank...rank
.beyanname
@differentiable(wrt: self) public func sum(squeezingAxes axes: Tensor<Int32>) -> Tensor
parametreler
axes
The dimensions to reduce.
Returns the sum along the specified axes. The reduced dimensions are removed.
ön koşul
Each value inaxes
must be in the range-rank...rank
.beyanname
@differentiable(wrt: self) public func sum(squeezingAxes axes: [Int]) -> Tensor
parametreler
axes
The dimensions to reduce.
Returns the sum along the specified axes. The reduced dimensions are removed.
ön koşul
Each value inaxes
must be in the range-rank...rank
.beyanname
@differentiable(wrt: self) public func sum(squeezingAxes axes: Int...) -> Tensor
parametreler
axes
The dimensions to reduce.
beyanname
@differentiable(wrt: self) public func sum() -> Tensor
Returns the sum along the specified axes. The reduced dimensions are retained with value 1.
ön koşul
Each value inaxes
must be in the range-rank..<rank
.beyanname
@differentiable(wrt: self) public func sum(alongAxes axes: Tensor<Int32>) -> Tensor
parametreler
axes
The dimensions to reduce.
Returns the sum along the specified axes. The reduced dimensions are retained with value 1.
ön koşul
Each value inaxes
must be in the range-rank..<rank
.beyanname
@differentiable(wrt: self) public func sum(alongAxes axes: [Int]) -> Tensor
parametreler
axes
The dimensions to reduce.
Returns the sum along the specified axes. The reduced dimensions are retained with value 1.
ön koşul
Each value inaxes
must be in the range-rank..<rank
.beyanname
@differentiable(wrt: self) public func sum(alongAxes axes: Int...) -> Tensor
parametreler
axes
The dimensions to reduce.
Returns the product along the specified axes. The reduced dimensions are removed.
ön koşul
Each value inaxes
must be in the range-rank...rank
.beyanname
@differentiable(wrt: self) public func product(squeezingAxes axes: Tensor<Int32>) -> Tensor
parametreler
axes
The dimensions to reduce.
Returns the product along the specified axes. The reduced dimensions are removed.
ön koşul
Each value inaxes
must be in the range-rank...rank
.beyanname
@differentiable(wrt: self) public func product(squeezingAxes axes: [Int]) -> Tensor
parametreler
axes
The dimensions to reduce.
Returns the product along the specified axes. The reduced dimensions are removed.
ön koşul
Each value inaxes
must be in the range-rank...rank
.beyanname
@differentiable(wrt: self) public func product(squeezingAxes axes: Int...) -> Tensor
parametreler
axes
The dimensions to reduce.
beyanname
@differentiable(wrt: self) public func product() -> Tensor
Returns the product along the specified axes. The reduced dimensions are retained with value 1.
ön koşul
Each value inaxes
must be in the range-rank..<rank
.beyanname
public func product(alongAxes axes: Tensor<Int32>) -> Tensor
parametreler
axes
The dimensions to reduce.
Returns the product along the specified axes. The reduced dimensions are retained with value 1.
ön koşul
Each value inaxes
must be in the range-rank..<rank
.beyanname
public func product(alongAxes axes: [Int]) -> Tensor
parametreler
axes
The dimensions to reduce.
Returns the product along the specified axes. The reduced dimensions are retained with value 1.
ön koşul
Each value inaxes
must be in the range-rank..<rank
.beyanname
public func product(alongAxes axes: Int...) -> Tensor
parametreler
axes
The dimensions to reduce.
Returns the arithmetic mean along the specified axes. The reduced dimensions are removed.
ön koşul
Each value inaxes
must be in the range-rank...rank
.beyanname
@differentiable(wrt: self) public func mean(squeezingAxes axes: Tensor<Int32>) -> Tensor
parametreler
axes
The dimensions to reduce.
Returns the arithmetic mean along the specified axes. The reduced dimensions are removed.
ön koşul
Each value inaxes
must be in the range-rank...rank
.beyanname
@differentiable(wrt: self) public func mean(squeezingAxes axes: [Int]) -> Tensor
parametreler
axes
The dimensions to reduce.
Returns the arithmetic mean along the specified axes. The reduced dimensions are removed.
ön koşul
Each value inaxes
must be in the range-rank...rank
.beyanname
@differentiable(wrt: self) public func mean(squeezingAxes axes: Int...) -> Tensor
parametreler
axes
The dimensions to reduce.
beyanname
@differentiable(wrt: self) public func mean() -> Tensor
Returns the arithmetic mean along the specified axes. The reduced dimensions are retained with value 1.
ön koşul
Each value inaxes
must be in the range-rank..<rank
.beyanname
@differentiable(wrt: self) public func mean(alongAxes axes: Tensor<Int32>) -> Tensor
parametreler
axes
The dimensions to reduce.
Returns the arithmetic mean along the specified axes. The reduced dimensions are retained with value 1.
ön koşul
Each value inaxes
must be in the range-rank..<rank
.beyanname
@differentiable(wrt: self) public func mean(alongAxes axes: [Int]) -> Tensor
parametreler
axes
The dimensions to reduce.
Returns the arithmetic mean along the specified axes. The reduced dimensions are retained with value 1.
ön koşul
Each value inaxes
must be in the range-rank..<rank
.beyanname
@differentiable(wrt: self) public func mean(alongAxes axes: Int...) -> Tensor
parametreler
axes
The dimensions to reduce.
Returns the variance along the specified axes. The reduced dimensions are removed. Does not apply Bessel's correction.
ön koşul
Each value inaxes
must be in the range-rank..<rank
.beyanname
@differentiable(wrt: self) public func variance(squeezingAxes axes: Tensor<Int32>) -> Tensor
parametreler
axes
The dimensions to reduce.
Returns the variance along the specified axes. The reduced dimensions are removed. Does not apply Bessel's correction.
ön koşul
Each value inaxes
must be in the range-rank..<rank
.beyanname
@differentiable(wrt: self) public func variance(squeezingAxes axes: [Int]) -> Tensor
parametreler
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.
ön koşul
Each value inaxes
must be in the range-rank..<rank
.beyanname
@differentiable(wrt: self) public func variance(squeezingAxes axes: Int...) -> Tensor
parametreler
axes
The dimensions to reduce.
beyanname
@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.
ön koşul
Each value inaxes
must be in the range-rank..<rank
.beyanname
@differentiable(wrt: self) public func variance(alongAxes axes: Tensor<Int32>) -> Tensor
parametreler
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.
ön koşul
Each value inaxes
must be in the range-rank..<rank
.beyanname
@differentiable(wrt: self) public func variance(alongAxes axes: [Int]) -> Tensor
parametreler
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.
ön koşul
Each value inaxes
must be in the range-rank..<rank
.beyanname
@differentiable(wrt: self) public func variance(alongAxes axes: Int...) -> Tensor
parametreler
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.
ön koşul
axis
must be in the range-rank..<rank
.beyanname
@differentiable(wrt: self) public func cumulativeSum( alongAxis axis: Int, exclusive: Bool = false, reverse: Bool = false ) -> Tensor
parametreler
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.
Geri dönüş değeri
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.
ön koşul
axis.rank
must be0
.ön koşul
axis
must be in the range-rank..<rank
.beyanname
@differentiable(wrt: self) public func cumulativeSum( alongAxis axis: Tensor<Int32>, exclusive: Bool = false, reverse: Bool = false ) -> Tensor
parametreler
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.
Geri dönüş değeri
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.
ön koşul
axis
must be in the range-rank..<rank
.beyanname
@differentiable(wrt: self) public func cumulativeProduct( alongAxis axis: Int, exclusive: Bool = false, reverse: Bool = false ) -> Tensor
parametreler
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.
Geri dönüş değeri
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.
ön koşul
axis
must have rank0
.ön koşul
axis
must be in the range-rank..<rank
.beyanname
@differentiable(wrt: self) public func cumulativeProduct( alongAxis axis: Tensor<Int32>, exclusive: Bool = false, reverse: Bool = false ) -> Tensor
parametreler
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.
Geri dönüş değeri
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.ön koşul
Each value inaxes
must be in the range-rank..<rank
.beyanname
@differentiable(wrt: self) public func standardDeviation(squeezingAxes axes: Tensor<Int32>) -> Tensor
parametreler
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.ön koşul
Each value inaxes
must be in the range-rank..<rank
.beyanname
@differentiable(wrt: self) public func standardDeviation(squeezingAxes axes: [Int]) -> Tensor
parametreler
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.ön koşul
Each value inaxes
must be in the range-rank..<rank
.beyanname
@differentiable(wrt: self) public func standardDeviation(squeezingAxes axes: Int...) -> Tensor
parametreler
axes
The dimensions to reduce.
Returns the standard deviation of all elements in this tensor. Does not apply Bessel's correction.
ön koşul
Each value inaxes
must be in the range-rank..<rank
.beyanname
@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.ön koşul
Each value inaxes
must be in the range-rank..<rank
.beyanname
@differentiable(wrt: self) public func standardDeviation(alongAxes axes: Tensor<Int32>) -> Tensor
parametreler
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.ön koşul
Each value inaxes
must be in the range-rank..<rank
.beyanname
@differentiable(wrt: self) public func standardDeviation(alongAxes axes: [Int]) -> Tensor
parametreler
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.ön koşul
Each value inaxes
must be in the range-rank..<rank
.beyanname
@differentiable(wrt: self) public func standardDeviation(alongAxes axes: Int...) -> Tensor
parametreler
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.ön koşul
Each value inaxes
must be in the range-rank..<rank
.beyanname
@differentiable(wrt: self) public func logSumExp(squeezingAxes axes: Tensor<Int32>) -> Tensor
parametreler
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.ön koşul
Each value inaxes
must be in the range-rank..<rank
.beyanname
@differentiable(wrt: self) public func logSumExp(squeezingAxes axes: [Int]) -> Tensor
parametreler
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.ön koşul
Each value inaxes
must be in the range-rank..<rank
.beyanname
@differentiable(wrt: self) public func logSumExp(squeezingAxes axes: Int...) -> Tensor
parametreler
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.beyanname
@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.ön koşul
Each value inaxes
must be in the range-rank..<rank
.beyanname
@differentiable(wrt: self) public func logSumExp(alongAxes axes: Tensor<Int32>) -> Tensor
parametreler
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.ön koşul
Each value inaxes
must be in the range-rank..<rank
.beyanname
@differentiable(wrt: self) public func logSumExp(alongAxes axes: [Int]) -> Tensor
parametreler
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.ön koşul
Each value inaxes
must be in the range-rank..<rank
.beyanname
@differentiable(wrt: self) public func logSumExp(alongAxes axes: Int...) -> Tensor
parametreler
axes
The dimensions to reduce.
Returns the mean and variance of this tensor along the specified axes. The reduced dimensions are removed.
ön koşul
axes
must have rank1
.ön koşul
Each value inaxes
must be in the range-rank..<rank
.beyanname
@differentiable(wrt: self) public func moments(squeezingAxes axes: Tensor<Int32>) -> Moments<Scalar>
parametreler
axes
The dimensions to reduce.
Returns the mean and variance of this tensor along the specified axes. The reduced dimensions are removed.
ön koşul
Each value inaxes
must be in the range-rank..<rank
.beyanname
@differentiable(wrt: self) public func moments(squeezingAxes axes: [Int]) -> Moments<Scalar>
parametreler
axes
The dimensions to reduce.
Returns the mean and variance of this tensor along the specified axes. The reduced dimensions are removed.
ön koşul
Each value inaxes
must be in the range-rank..<rank
.beyanname
@differentiable(wrt: self) public func moments(squeezingAxes axes: Int...) -> Moments<Scalar>
parametreler
axes
The dimensions to reduce.
Returns the mean and variance of this tensor's elements.
beyanname
@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
.ön koşul
axes
must have rank1
.ön koşul
Each value inaxes
must be in the range-rank..<rank
.beyanname
@differentiable(wrt: self) public func moments(alongAxes axes: Tensor<Int32>) -> Moments<Scalar>
parametreler
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
.ön koşul
Each value inaxes
must be in the range-rank..<rank
.beyanname
@differentiable(wrt: self) public func moments(alongAxes axes: [Int]) -> Moments<Scalar>
parametreler
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
.ön koşul
Each value inaxes
must be in the range-rank..<rank
.beyanname
@differentiable(wrt: self) public func moments(alongAxes axes: Int...) -> Moments<Scalar>
parametreler
axes
The dimensions to reduce.
Performs matrix multiplication between two tensors and produces the result.
beyanname
@differentiable public static func • (lhs: Tensor, rhs: Tensor) -> Tensor
beyanname
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
.beyanname
@differentiable(wrt: (self, offset, scale) public func batchNormalized( alongAxis axis: Int, offset: Tensor = Tensor(0), scale: Tensor = Tensor(1), epsilon: Scalar = 0.001 ) -> Tensor
parametreler
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.
beyanname
@differentiable public static func concatenate(_ lhs: Tensor, _ rhs: Tensor) -> Tensor
Adds two values and produces their sum.
beyanname
@differentiable public static func sum(_ lhs: Tensor, _ rhs: Tensor) -> Tensor
Averages two values.
beyanname
@differentiable public static func average(_ lhs: Tensor, _ rhs: Tensor) -> Tensor
Multiplies two values.
beyanname
@differentiable public static func multiply(_ lhs: Tensor, _ rhs: Tensor) -> Tensor
Stack two values.
beyanname
@differentiable public static func stack(_ lhs: Tensor, _ rhs: Tensor) -> Tensor
beyanname
@derivative init(shape: scalars)
beyanname
public static func == (lhs: Tensor, rhs: Tensor) -> Bool
beyanname
public static func != (lhs: Tensor, rhs: Tensor) -> Bool
beyanname
public func encode(to encoder: Encoder) throws
beyanname
public init(from decoder: Decoder) throws
The scalar zero tensor.
beyanname
public static var zero: Tensor { get }
Adds two tensors and produces their sum.
Note
+
supports broadcasting.beyanname
@differentiable public static func + (lhs: Tensor, rhs: Tensor) -> Tensor
Subtracts one tensor from another and produces their difference.
Note
-
supports broadcasting.beyanname
@differentiable public static func - (lhs: Tensor, rhs: Tensor) -> Tensor
The scalar one tensor.
beyanname
public static var one: Tensor { get }
Returns the element-wise reciprocal of
self
.beyanname
public var reciprocal: Tensor { get }
Multiplies two tensors element-wise and produces their product.
Note
.*
supports broadcasting.beyanname
public static func .* (lhs: Tensor, rhs: Tensor) -> Tensor
beyanname
public typealias TangentVector = Tensor
beyanname
public var zeroTangentVectorInitializer: () -> TangentVector { get }
Adds an annotation.
Note: Only X10 is supported. For other backends, umodified
self
is returned.beyanname
@differentiable(wrt: self) public func annotate(_ annotation: String) -> Tensor<Scalar>
parametreler
annotation
The annotation to be added.
Geri dönüş değeri
The annotated tensor.
beyanname
@derivative func vjpAnnotate(_ annotation: String) -> ( value: Tensor<Scalar>, pullback: (Tensor<Scalar>) -> Tensor<Scalar> )