nuts-ml
nuts-ml copied to clipboard
Get output/activation of a network layer
Example code for Keras:
@nut_function def GetActivations(batch, model, layer, istrain=1): from keras import backend as K
f = K.function([model.input, K.learning_phase()],
[model.get_layer(layer).output])
return f([batch[0], istrain])
build_batch >> GetActivations(network.model) >> FlattenCol(0) >> Collect()
Having a network function for it would be nice, e.g. build_batch >> network.activation('layername') >> Collect()