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

beginner_source/basics/saveloadrun_tutorial.py 번역 #938

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion beginner_source/basics/saveloadrun_tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,13 @@

########################
# 다음과 같이 모델을 불러올 수 있습니다:
#
# `Saving and loading torch.nn.Modules <pytorch.org/docs/main/notes/serialization.html#saving-and-loading-torch-nn-modules>`__에서 설명한 것처럼,
# ``state_dict``를 저장하는 것이 가장 좋은 방법으로 간주됩니다.
# 하지만 아래에서는 ``weights_only=False``를 사용하는데,
# 이는 모델을 로드하는 것을 포함하기 때문이며, ``torch.save``의 레거시 사용 사례입니다.

model = torch.load('model.pth')
model = torch.load('model.pth', weights_only=False),

########################
# .. note:: 이 접근 방식은 Python `pickle <https://docs.python.org/3/library/pickle.html>`_ 모듈을 사용하여 모델을 직렬화(serialize)하므로, 모델을 불러올 때 실제 클래스 정의(definition)를 적용(rely on)합니다.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def forward(self, x):
# 매치되도록 해 주면 됩니다.
#

netB.load_state_dict(torch.load(PATH), strict=False)
netB.load_state_dict(torch.load(PATH, weights_only=True), strict=False)


######################################################################
Expand Down