시작하기무료로 시작하기

학습된 네트워크에서 커널 추출하기

모델을 해석하는 한 가지 방법은 합성곱 레이어의 커널 특성을 살펴보는 것입니다. 이 연습 문제에서는 hdf5 파일에 저장해 둔 가중치를 가진 합성곱 신경망에서 커널 하나를 추출해 보겠습니다.

이 연습은 강의의 일부입니다

Keras로 배우는 이미지 모델링

강의 보기

연습 안내

  • 파일 weights.hdf5에서 모델로 가중치를 로드하세요.
  • layers 속성에서 모델의 첫 번째 합성곱 레이어를 가져오세요.
  • .get_weights() 메서드를 사용해 이 레이어의 가중치를 추출하세요.

실습형 인터랙티브 연습

이 예제를 이 샘플 코드를 완성하여 풀어보세요.

# Load the weights into the model
model.____('weights.hdf5')

# Get the first convolutional layer from the model
c1 = model.____[0]

# Get the weights of the first convolutional layer
weights1 = c1.____()

# Pull out the first channel of the first kernel in the first layer
kernel = weights1[0][...,0, 0]
print(kernel)
코드 편집 및 실행