Skip to Content
밑바닥부터 시작하는 딥러닝 5
book

밑바닥부터 시작하는 딥러닝 5

by 사이토 고키, 개앞맵시(이복연)
October 2024
Beginner to intermediate
340 pages
7h 38m
Korean
Hanbit Media, Inc.
Content preview from 밑바닥부터 시작하는 딥러닝 5
170
밑바닥부터 시작하는 딥러닝 5
6.3.1
Parameter
클래스와
Module
클래스
torch
.
nn
.
Parameter
클래스부터 설명하겠습니다.
Parameter
Tensor
클래스를 상속받은
클래스이며 인수로
tensor
인스턴스를 건네 생성합니다. 예를 들어 다음과 같이 사용합니다.
import torch
import torch
.
nn as nn
W
=
nn
.
Parameter(torch
.
zeros(1, 1))
b
=
nn
.
Parameter(torch
.
zeros(1))
print(W)
print(b)
실행 결과
Parameter containing:
tensor([[0
.
]], requires_grad
=
True)
Parameter containing:
tensor([0
.
], requires_grad
=
True)
Parameter
는 기본적으로
requires
_
grad
=
True
로 설정되어 있습니다. 지금 코드에서
W
b
tensor
와 동일하게 취급할 수 있습니다. 역전파하여 기울기를 구할 수도 있죠. 참고로
Parameter
인스턴스를
print
( )로 출력하면 ‘
Parameter
containing
:’이라는 문구가 가장 먼
저 출력됩니다.
Parameter
클래스는
Module
클래스와 함께 사용할 때 제대로 된 위력을 발휘합니다. 사용
예를 먼저 보겠습니다. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

밑바닥부터 시작하는 딥러닝 4

밑바닥부터 시작하는 딥러닝 4

사이토 고키

Publisher Resources

ISBN: 9791169212960