딥러닝 (Deep Learning)/tensorflow, keras

[tensorflow, keras] 딥러닝 기본 코드(2-2) 모델 가중치 확인

DS지니 2021. 10. 14. 18:10
728x90
반응형
[youtube] Deep Learning Full Tutorial Course using TensorFlow and Keras - 이수안컴퓨터연구소 참고

 

🧡목차

딥러닝 구조 및 학습

 

2. 모델(Model)

2) 모델 가중치 확인

 


 

딥러닝 구조 및 학습

  • 딥러닝 구조와 학습에 필요한 요소
    • 모델(네트워크)를 구성하는 레이어(layer)
    • 입력 데이터와 그에 대한 목적(결과)
    • 학습시에 사용할 피드백을 정의하는 손실 함수(loss function)
    • 학습 진행 방식을 결정하는 옵티마이저(optimizer)

 

2. 모델(Model)

  • 딥러닝 모델은 레이어로 만들어진 비순환 유향 그래프(Directed Acyclic Graph, DAG) 구조

 

2) 모델 가중치 확인

 

- 모델 제작

inputs = Input(shape=(28,28,1))
x = Flatten(input_shape=(28,28,1))(inputs)
x = Dense(300, activation='relu')(x)
x = Dense(100, activation='relu')(x)
x = Dense(10, activation='softmax')(x)

model = Model(inputs=inputs, outputs=x)
model.summary()

 

- 모델 레이어 확인

model.layers

 

- 특정 레이어 확인

hidden_2 = model.layers[2]
hidden_2.name

dense_19

 

model.get_layer('dense_19') is hidden_2

True

 

 

- 모델의 가중치, 바이어스 확인

weights, biases = hidden_2.get_weights()
print(weights.shape)
print(biases.shape)

(784, 300)

(300,)

 

print(weights)
print(biases)

 

728x90
반응형