def __init__(self):
super(Model, self).__init__()
self.flatten = Flatten()
self.dense1 = Dense(256, activation = 'relu')
self.dense2 = Dense(128, activation = 'relu')
self.dense3 = Dense(classes, activation = 'softmax')
def call(self, x):
print(x.shape)
x = self.flatten(x)
print(x.shape)
x = self.dense1(x)
print(x.shape)
x = self.dense2(x)
print(x.shape)
y = self.dense3(x)
print(y.shape)
print(tf.matmul(x, self.w))
return y
한층마다 가중치랑 편향 읽어오고 싶은데 아는사람?
self.dense1.get_weights() 안댐?
call 층에 print(self.dense1.get_weights()) 이리 쓰면됨? 에러나네..
혹시 저런 방법으로 Tensorflow 알려주는 책 있어?
저런 방식으로 공부하고 싶은데 찾아보니 잘 안보임...
찾았다!Dense Layer에 텐서를 통과 시키기 전까지는
가중치랑 편향이 정의가 안됨.
def call(self, x): x = self.flatten(x) x = self.dense1(x) print(self.dense1.get_weights()) ...(중략) return y
텐서플로 귀찮은 부분이 많은듯 빨리 파이토치로 넘어오도록
와 진짜 고마워 이런거 알려주는 책이 없어서 파이토치로 넘어갈려고 해 ㅠㅠ 그래서 책은 구매할려고 하는데 구매해도 오는데 까지 시간이 걸리니깐 혹시 기울기 구베벡터 값도 불러오는 방법이 있어?
밖이라 직접 돌려 볼 순 없는데,
(1) Dense 클래스의 backward 메소드를 건드리거나
(2) gradient tape 써서 미분값 얻어내면 될거 같음
아래 링크는 gradient tape 통해서 미분 값 출력하는 예시에 대한 것임
https://www.tensorflow.org/guide/autodiff?hl=ko