vmtmxmf5 / Pytorch-

pytorch로 머신러닝~딥러닝 구현
3 stars 0 forks source link

pytorch VS tensorflow #1

Open vmtmxmf5 opened 2 years ago

vmtmxmf5 commented 2 years ago

Pytorch 명령어

tf torch
tf.Variable() torch.FloatTensor()
torch.LongTensor()
axis dim
a.shape a.shape
a.size()
a.reshape() a.view()
a.reshape()
a[tf.newaxis, ...] a[None, ...]
a.unsqueeze(dim)
tf.concat([x, y], axis=) torch.cat([x, y], dim=)
tf.zeros_like() torch.zeros_like()

덮어쓰기 기능

a.mul_(2)

index_fill

tmp.indexfill(dim, index=torch.tensor([0,2]), val)

병합

1. torch.cat할 때 dim=0의 사이즈만 자유롭고 나머지는 같아야 함
2. cat vs stack
torch.cat([a.unsqueeze(0), b.unsqueeze(0), c.unsqueeze(0)])
torch.stack([a,b,c])

random uniform dist.

torch.empty(4, 2).uniform_(0,1)