title: Keras-surgeon: For pruning and Model optimization
body: <p>I am working on a Convolutional Neural Net built using Keras. And since the final model needs to be deployed on a processing unit with less processing capabilities, I started looking for ways to reduce the resources it'd consume. Luckily, I came across this library in Keras, <a href="https://github.com/BenWhetton/keras-surgeon" rel="nofollow noreferrer">Keras-surgeon</a>, that helps in modifying trained Keras models.</p>
  
  <p>I'm trying to delete channels in one of my Conv Net layers (and will proceed further on other layers). Although, documentation is very straightforward and simple, and people who have used this also praise it, when I tried to use it, it returns a weird type-error:</p>
  
  <pre><code>from kerassurgeon import Surgeon
  
  surgeon = Surgeon(model_final)
  layer_1 = model_final.layers[1] # selecting 2nd layer
  
  surgeon.add_job('delete_channels', layer_1, channels=[4,7,3])
  new_model = surgeon.operate()
  
  ---------------------------------------------------------------------------
  TypeError                                 Traceback (most recent call last)
  &lt;ipython-input-292-77c377538a52&gt; in &lt;module&gt;
        5 
        6 surgeon.add_job('delete_channels', layer_1, channels=[4,7,3])
  ----&gt; 7 new_model = surgeon.operate()
  
  ~/anaconda3/envs/Learning/lib/python3.6/site-packages/kerassurgeon/surgeon.py in operate(self)
      150         for node in sorted_nodes:
      151             # Rebuild submodel up to this node
  --&gt; 152             sub_output_nodes = utils.get_node_inbound_nodes(node)
      153             outputs, output_masks = self._rebuild_graph(self.model.inputs,
      154                                                         sub_output_nodes)
  
  ~/anaconda3/envs/Learning/lib/python3.6/site-packages/kerassurgeon/utils.py in get_node_inbound_nodes(node)
       88 def get_node_inbound_nodes(node):
       89     return [get_inbound_nodes(node.inbound_layers[i])[node_index]
  ---&gt; 90             for i, node_index in enumerate(node.node_indices)]
       91 
       92 
  
  TypeError: 'int' object is not iterable
  </code></pre>
  
  <ol>
  <li><p>What exactly am I doing wrong here? </p></li>
  <li><p>Also, can anyone point out anything that I could use to run the keras model on, to see its resources consumption (memory and CPU etc.)? (It'll be a big help!) </p></li>
  <li>And what other approaches I can take to have a model that takes less resources without compromising accuracy?  </li>
  </ol>
  
  <p>Any help will be much appreciated..!</p>