...
Code Block | ||
---|---|---|
| ||
from keras import backend as K conv0 = K.function([model.layers[0].input], [model.layers[0].output]) out0=conv0([X])[0] out0.shape Out[15]: (24, 2, 363, 284) # this is a batch of 24 samples, there are two channels of outputs, 2 feature maps # take a look at the two channels imshow(out0[0,0,:,:]) imshow(out0[0,1,:,:]) # take a look at the final output of the convnet layers, # since we use batch normalization that behaves differently between training and test, # we must make this an argument and pass a value when we use the function: l7fn = K.function([model.layers[0].input, K.learning_phase()],[model.layers[7].output]) convout = l7fn([X,False])[0] convout.shape Out[24]: (24, 6, 22, 17) # look at one of the output channels: imshow(convout[0,0,:,:]) # take a look at the variables so far weights = model.weights() # need to match up with model.summary() to see what is what # kernel for first convolutional layer weights[0].shape (2,1,4,4) |
Do control+D when done, to quit IPython, model will keep training
Exercises
Explore more of the model
...