"Torch"의 두 판 사이의 차이
ph
잔글 (→narrow) |
잔글 (→narrow) |
||
20번째 줄: | 20번째 줄: | ||
===narrow=== | ===narrow=== | ||
:narrow(dim, offset, length) | :narrow(dim, offset, length) | ||
− | 행렬의 slice를 가져옴. dim=1은 row, 2는 column, 3이상도 가능. <br /> | + | 행렬의 slice를 가져옴. dim=1은 row, 2는 column, 3이상도 가능.''(row가 먼저임에 주의)'' <br /> |
offset=1이면 첫줄부터 가져옴. 즉 start index라고 보면 된다.<br /> | offset=1이면 첫줄부터 가져옴. 즉 start index라고 보면 된다.<br /> | ||
length는 해당 dimension의 vector몇개를 가져올지 지정. 즉 length=3이라고 해서 숫자 세개가 오는 것이 아니다. 5\(\times\)4 행렬에서 <c>narrow(1,3,2)</c>하면, 다음 색칠한 두줄을 반환한다. | length는 해당 dimension의 vector몇개를 가져올지 지정. 즉 length=3이라고 해서 숫자 세개가 오는 것이 아니다. 5\(\times\)4 행렬에서 <c>narrow(1,3,2)</c>하면, 다음 색칠한 두줄을 반환한다. |
2017년 7월 12일 (수) 16:43 판
links
iTorch
https://github.com/facebook/iTorch
ipython같이 쓸 수 있음.
etc
storage
Tensor is a particular way of viewing a Storage. storage로 접근하면 내부 배열에 순차적으로 접근 가능. matlab에서 2차원 이상 배열을 1차원배열 index로 접근하는 것과 동일.
x = torch.Tensor(4,5) s = x:storage() for i=1,s:size() do -- fill up the Storage s[i] = i end
apply
x:apply(function(x) return x end)
narrow
:narrow(dim, offset, length)
행렬의 slice를 가져옴. dim=1은 row, 2는 column, 3이상도 가능.(row가 먼저임에 주의)
offset=1이면 첫줄부터 가져옴. 즉 start index라고 보면 된다.
length는 해당 dimension의 vector몇개를 가져올지 지정. 즉 length=3이라고 해서 숫자 세개가 오는 것이 아니다. 5\(\times\)4 행렬에서 narrow(1,3,2)하면, 다음 색칠한 두줄을 반환한다.
0 | 0 | 0 | 0 |
0 | 0 | 0 | 0 |
0 | 0 | 0 | 0 |
0 | 0 | 0 | 0 |
0 | 0 | 0 | 0 |