Pytorch: νŒ¨λ”©μ΄ nn.Conv1dμ—μ„œ λΆ€λ™μœΌλ‘œ 섀정될 λ•Œ ν˜Όλ™λ˜λŠ” 였λ₯˜ λ©”μ‹œμ§€

에 λ§Œλ“  2017λ…„ 05μ›” 16일  Β·  3μ½”λ©˜νŠΈ  Β·  좜처: pytorch/pytorch

Conv λ ˆμ΄μ–΄λ₯Ό λ§Œλ“€κ³  μ‹€μˆ˜λ‘œ νŒ¨λ”©μ„ float둜 μ „λ‹¬ν•˜λ©΄ ν˜Όλž€μŠ€λŸ¬μš΄ 였λ₯˜ λ©”μ‹œμ§€κ°€ ν‘œμ‹œλ˜μ–΄ λ””λ²„κ·Έν•˜κΈ°κ°€ 더 μ–΄λ €μ›Œμ§‘λ‹ˆλ‹€. λ˜ν•œ μ •λ°©ν–₯ 패슀λ₯Ό μˆ˜ν–‰ν•  λ•Œ 였λ₯˜κ°€ λ°œμƒν•©λ‹ˆλ‹€.

self.cnn = nn.Conv1d(in_channels=self.input_size, out_channels=self.num_filters,kernel_size=kw_l,padding=1.0)
self.cnn(inp)  # error is thrown in this line

였λ₯˜ λ©”μ‹œμ§€λŠ” "λŸ°νƒ€μž„ 였λ₯˜: 인수 1은 νŠœν”Œμ΄ μ•„λ‹ˆλΌ int νŠœν”Œμ΄μ–΄μ•Ό ν•©λ‹ˆλ‹€"μž…λ‹ˆλ‹€.

λͺ¨λ“  3 λŒ“κΈ€

λͺ…ν™•νžˆ ν•˜μžλ©΄ 잘λͺ»λœ νŠœν”Œμ˜ μœ ν˜•μ„ ν¬ν•¨ν•˜λ„λ‘ RuntimeErrorκ°€ μ—…λ°μ΄νŠΈλ˜λ©΄ 도움이 될 수 μžˆλ‹€κ³  μƒκ°ν•©λ‹ˆλ‹€.

import torch
import torch.nn as nn
from torch.autograd import Variable
input = Variable(torch.randn(1, 1, 10))
output = nn.Conv1d(1, 1, 3, padding=1)(input)  # fine
output = nn.Conv1d(1, 1, 3, padding=1.0)(input)  # error

이 였λ₯˜ λ©”μ‹œμ§€λŠ” TupleParser 에 μ˜ν•΄ λ°œμƒν•˜λ©°, 이 μ‹œμ μ—μ„œ ꡬ문 뢄석 쀑인 λ§€κ°œλ³€μˆ˜λŠ” μ•Œμ§€ λͺ»ν•˜κ³  λ§€κ°œλ³€μˆ˜μ˜ 인덱슀(인수 λͺ©λ‘μ— 있음)만 μ•Œ 수 μžˆμŠ΅λ‹ˆλ‹€.

νŠœν”Œ νŒŒμ„œλŠ” autograd.functions.* 둜 λ§€κ°œλ³€μˆ˜λ₯Ό ꡬ문 λΆ„μ„ν•˜λŠ” 데만 μ‚¬μš©λ˜λ―€λ‘œ TupleParser::parse ν•¨μˆ˜λ₯Ό ν™•μž₯ν•˜μ—¬ λ§€κ°œλ³€μˆ˜ 이름도 κ°€μ Έμ™€μ„œ TupleParser::invalid_type 둜 전달할 수 μžˆμŠ΅λ‹ˆλ‹€. 더 μ˜λ―ΈμžˆλŠ” 였λ₯˜λ₯Ό throwν•©λ‹ˆκΉŒ?

μ•„λ‹ˆλ©΄ 파이썬 μˆ˜μ€€μ—μ„œ μ΄λŸ¬ν•œ μœ ν˜• 검사λ₯Ό μΆ”κ°€ν•  수 μžˆμŠ΅λ‹ˆκΉŒ?

@apaszke @soumith μ„ ν˜Έν•˜λŠ” 방법/λŒ€μ•ˆμ„ μ•Œλ €μ£Όμ‹œλ©΄ PR을 λ³΄λ‚΄λ“œλ¦¬κ² μŠ΅λ‹ˆλ‹€.

νŠœν”Œ νŒŒμ„œμ— λ§€κ°œλ³€μˆ˜ 이름을 μΆ”κ°€ν•˜λŠ” 것이 λ‚˜μ—κ²Œ μ’‹κ²Œ λ“€λ¦½λ‹ˆλ‹€.

이 νŽ˜μ΄μ§€κ°€ 도움이 λ˜μ—ˆλ‚˜μš”?
0 / 5 - 0 λ“±κΈ‰