Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

print out the shape of each layer in the net architecture

In Keras, we can define the network as follows. Are there any way to output the shape after each layer. For instance, I want to print out the shape of inputs after the line defining inputs, then print out the shape of conv1 after the line defining conv1, etc.

inputs = Input((1, img_rows, img_cols))
conv1 = Convolution2D(64, 3, 3, activation='relu', init='lecun_uniform', W_constraint=maxnorm(3), border_mode='same')(inputs)
conv1 = Convolution2D(64, 3, 3, activation='relu', init='lecun_uniform', W_constraint=maxnorm(3), border_mode='same')(conv1)
pool1 = MaxPooling2D(pool_size=(2, 2))(conv1)

conv2 = Convolution2D(128, 3, 3, activation='relu', init='lecun_uniform', W_constraint=maxnorm(3), border_mode='same')(pool1)
conv2 = Convolution2D(128, 3, 3, activation='relu', init='lecun_uniform', W_constraint=maxnorm(3), border_mode='same')(conv2)
pool2 = MaxPooling2D(pool_size=(2, 2))(conv2)
like image 774
user288609 Avatar asked Dec 23 '22 23:12

user288609


1 Answers

Just using model.summary(), which gives you pretty print.

like image 128
daoliker Avatar answered Dec 30 '22 20:12

daoliker