텐서플로우 작업

  • 추가하다
  • 덜다
  • 곱하다
  • 나누다
  • 정사각형
  • 모양 변경

텐서 추가

tensorA.add(tensorB) 를 사용하여 두 개의 텐서를 추가할 수 있습니다 .

예시

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] ]


텐서 빼기

tensorA.sub(tensorB) 를 사용하여 두 개의 텐서를 뺄 수 있습니다 .

예시

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] ]


텐서 곱셈

tensorA.mul(tensorB) 를 사용하여 두 개의 텐서를 곱할 수 있습니다 .

예시

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 ]


텐서 부문

tensorA.div(tensorB) 를 사용하여 두 개의 텐서를 나눌 수 있습니다 .

예시

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 ]


텐서 스퀘어

tensor.square() 를 사용하여 텐서를 제곱할 수 있습니다 .

예시

const tensorA = tf.tensor([1, 2, 3, 4]);

// Tensor Square
const tensorNew = tensorA.square();

// Result [ 1, 4, 9, 16 ]


텐서 재구성

텐서의 요소 수는 모양의 크기를 곱한 것입니다.

같은 크기의 다른 모양이 있을 수 있으므로 텐서를 같은 크기의 다른 모양으로 바꾸는 것이 종종 유용합니다.

tensor.reshape() 를 사용하여 텐서를 재구성할 수 있습니다 .

예시

const tensorA = tf.tensor([[1, 2], [3, 4]]);
const tensorB = tensorA.reshape([4, 1]);

// Result: [ [1], [2], [3], [4] ]