TensorFlow İşlemleri
- Eklemek
- çıkar
- Çarpmak
- Bölmek
- Meydan
- yeniden şekillendir
Tensör Ekleme
tensorA.add(tensorB) kullanarak iki tensör ekleyebilirsiniz :
Örnek
const tensorA = tf.tensor([[1, 2], [3, 4], [5, 6]]);
const tensorB = tf.tensor([[1,-1], [2,-2], [3,-3]]);
// Tensor Addition
const tensorNew = tensorA.add(tensorB);
// Result: [ [2, 1], [5, 2], [8, 3] ]
Tensör Çıkarma
tensorA.sub(tensorB) kullanarak iki tensörü çıkarabilirsiniz :
Örnek
const tensorA = tf.tensor([[1, 2], [3, 4], [5, 6]]);
const tensorB = tf.tensor([[1,-1], [2,-2], [3,-3]]);
// Tensor Subtraction
const tensorNew = tensorA.sub(tensorB);
// Result: [ [0, 3], [1, 6], [2, 9] ]
Tensör Çarpımı
tensorA.mul(tensorB) kullanarak iki tensörü çarpabilirsiniz :
Örnek
const tensorA = tf.tensor([1, 2, 3, 4]);
const tensorB = tf.tensor([4, 4, 2, 2]);
// Tensor Multiplication
const tensorNew = tensorA.mul(tensorB);
// Result: [ 4, 8, 6, 8 ]
Tensör Bölümü
tensorA.div(tensorB) kullanarak iki tensörü bölebilirsiniz :
Örnek
const tensorA = tf.tensor([[1, 2], [3, 4], [5, 6]]);
const tensorB = tf.tensor([[1,-1], [2,-2], [3,-3]]);
// Tensor Division
const tensorNew = tensorA.div(tensorB);
// Result: [ 2, 2, 3, 4 ]
Tensör Karesi
tensor.square() kullanarak bir tensörün karesini alabilirsiniz :
Örnek
const tensorA = tf.tensor([1, 2, 3, 4]);
// Tensor Square
const tensorNew = tensorA.square();
// Result [ 1, 4, 9, 16 ]
Tensör Yeniden Şekillendirme
Bir tensördeki eleman sayısı, şekildeki boyutların çarpımıdır.
Aynı boyutta farklı şekiller olabileceğinden, bir tensörü aynı boyuttaki diğer şekillere yeniden şekillendirmek genellikle yararlıdır.
tensor.reshape() kullanarak bir tensörü yeniden şekillendirebilirsiniz :
Örnek
const tensorA = tf.tensor([[1, 2], [3, 4]]);
const tensorB = tensorA.reshape([4, 1]);
// Result: [ [1], [2], [3], [4] ]