Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

repackage_hidden의 역할이 뭔가요? #42

Open
eddiemaru101 opened this issue Jun 18, 2020 · 1 comment
Open

repackage_hidden의 역할이 뭔가요? #42

eddiemaru101 opened this issue Jun 18, 2020 · 1 comment

Comments

@eddiemaru101
Copy link

1_train_predictor.py 안에 있는 train 함수에서 아래 부분의 코드가 나와있는데

    hidden = model.repackage_hidden(hidden)
    hidden_ = model.repackage_hidden(hidden)

이 부분에서 repackage_hidden의 역할이 뭔가요?
밑에 나와있는 함수인데
제가 실력이 부족해서,
튜플에 담겨있는 h(t),c(t)를
다시 튜플에 담아서 return해주는 이유를 잘 이해 되지 않아서
질문합니다.

def repackage_hidden(self,h):
    """Wraps hidden states in new Variables, to detach them from their history."""
    if type(h) == tuple:
        return tuple(self.repackage_hidden(v) for v in h) # 이중 tuple을 푸는 역할
    else:
        return h.detach()
@chickenbestlover
Copy link
Owner

chickenbestlover commented Jun 18, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants