February 2018
Intermediate to advanced
262 pages
6h 59m
English
We will be using the same techniques that we used to calculate activations for style transfer. The following is the LayerActivations class with some minor modifications, as we are interested in extracting only outputs of a particular layer:
class LayerActivations(): features=[] def __init__(self,model): self.features = [] self.hook = model.register_forward_hook(self.hook_fn) def hook_fn(self,module,input,output): self.features.extend(output.view(output.size(0),-1).cpu().data) def remove(self): self.hook.remove()
Apart from the hook function, the rest of the code is similar to what we have used for style transfer. As we are capturing the outputs of all the images and storing ...
Read now
Unlock full access