모든 노드의 값은 계산 그래프 실행 간에 유지되지 않습니다. 변숫값은 예외로, 그래프 실행 간
에도 세션에 의해 유지됩니다(
12
장에서 보게 될 큐
queue
와 리더
reader
또한 일부 상태를 유지합
니다). 변수는 초기화될 때 일생이 시작되고 세션이 종료될 때까지 남아 있습니다.
이전 코드에서처럼
w
와
x
를 두 번 평가하지 않고
y
와
z
를 효율적으로 평가하려면 텐서플로가
한 번의 그래프 실행에서
y
와
z
를 모두 평가하도록 만들어야 합니다.
with tf
.
Session
()
as sess
:
y
_
val
,
z
_
val
=
sess
.
run
([
y
,
z
])
print
(
y
_
val
)
#
10
print
(
z
_
val
)
#
15
CAUTION
_
단일 프로세스 텐서플로에서는 같은 그래프를 재사용하더라도 여러 세션에서 어떤 상태도 공유
하지 않습니다(각 세션은 모든 변수에 대해 고유한 복사본을 가집니다). 분산 텐서플로(
1
2
장 참조)에서는 변
수 상태가 세션이 아니라 서버에 저장되므로 여러
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.
O’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
I wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
I’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
I'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.