torch.mul() / *

SeungHyun·2024년 4월 17일
0

pytorch

목록 보기
3/8
post-thumbnail

아래 내용은 pytorch 2.1.0 버전으로 작성됨.

0. 바로 사용하기

result = torch.mul(a, b)
  • a: input data1
  • b: input data2


1. 기본형

  1. torch 메서드로 사용
torch.mul(input, other, *, out=None) → Tensor
  1. torch.Tensor 메서드로 사용
torch_Tensor_1.mul(torch_Tensor_2) → Tensor
  1. 연산자 오버로딩
result = torch_Tensor_1 * torch_Tensor_2
  1. in-place 연산
torch.mul_(input_1, input_2)


2. 기능

  • 요소별 곱셈(element-wise)를 연산하여 torch.Tensor로 반환해줌
  • 특징
    • Broadcasting
    • In-place 연산 (torch.mul_())


3. 파라미터

input

  • 요소별 곱셈(element-wise)를 진행할 input data

other

  • 요소별 곱셈을 진행할 other input data. 브로드캐스팅이 가능 하기 때문에 scalar 값도 넣을 수 있다.


ref

profile
어디로 가야하오

0개의 댓글

관련 채용 정보