albermax / innvestigate

A toolbox to iNNvestigate neural networks' predictions!
Other
1.27k stars 233 forks source link

Error on an AWS GPU Instance #83

Closed nareshshah139 closed 6 years ago

nareshshah139 commented 6 years ago

Recently faced this error. Could really use some help.

Keras version 2.1.6

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-64-60cb4576f307> in <module>()
----> 1 analyzer_x = innvestigate.create_analyzer('gradient',k_model)

/usr/local/lib/python3.6/site-packages/innvestigate/analyzer/__init__.py in create_analyzer(name, model, **kwargs)
     87     :return: An instance of the chosen analyzer.
     88     """
---> 89     return analyzers[name](model, **kwargs)

/usr/local/lib/python3.6/site-packages/innvestigate/analyzer/gradient_based.py in __init__(self, model, **kwargs)
     97         ]
     98 
---> 99         super(Gradient, self).__init__(model, **kwargs)
    100 
    101     def _head_mapping(self, X):

/usr/local/lib/python3.6/site-packages/innvestigate/analyzer/base.py in __init__(self, model, reverse_verbose, reverse_clip_values, reverse_project_bottleneck_layers, reverse_check_min_max_values, reverse_check_finite, reverse_reapply_on_copied_layers, **kwargs)
    479         self._reverse_reapply_on_copied_layers = (
    480             reverse_reapply_on_copied_layers)
--> 481         super(ReverseAnalyzerBase, self).__init__(model, **kwargs)
    482 
    483     def _gradient_reverse_mapping(

/usr/local/lib/python3.6/site-packages/innvestigate/analyzer/base.py in __init__(self, model, neuron_selection_mode, **kwargs)
    305                  neuron_selection_mode="max_activation",
    306                  **kwargs):
--> 307         super(AnalyzerNetworkBase, self).__init__(model, **kwargs)
    308 
    309         if neuron_selection_mode not in ["max_activation", "index", "all"]:

/usr/local/lib/python3.6/site-packages/innvestigate/analyzer/base.py in __init__(self, model, disable_model_checks)
     84 
     85             checked = kgraph.model_contains(self._model, checks,
---> 86                                             return_only_counts=True)
     87             tmp = zip(iutils.to_list(checked), messages, types)
     88             for check_count, message, check_type in tmp:

/usr/local/lib/python3.6/site-packages/innvestigate/utils/keras/graph.py in model_contains(model, layer_condition, return_only_counts)
    336         single_condition = False
    337 
--> 338     layers = get_model_layers(model)
    339     collected_layers = []
    340     for condition in layer_condition:

/usr/local/lib/python3.6/site-packages/innvestigate/utils/keras/graph.py in get_model_layers(model)
    324             if kchecks.is_network(layer):
    325                 collect_layers(layer)
--> 326     collect_layers(model)
    327 
    328     return ret

/usr/local/lib/python3.6/site-packages/innvestigate/utils/keras/graph.py in collect_layers(container)
    322             assert layer not in ret
    323             ret.append(layer)
--> 324             if kchecks.is_network(layer):
    325                 collect_layers(layer)
    326     collect_layers(model)

/usr/local/lib/python3.6/site-packages/innvestigate/utils/keras/checks.py in is_network(layer)
    251     Is network in network?
    252     """
--> 253     return isinstance(layer, keras.engine.topology.Network)
    254 
    255 

AttributeError: module 'keras.engine.topology' has no attribute 'Network'

The same code works fine on my system.

sebastian-lapuschkin commented 6 years ago

FYI

which branch are you using?

albermax commented 6 years ago

Hi Naresh,

thank you for coming back to us! Please use the newest Keras version 2.2.0. That is the only one support (see setup.cfg). It seems like pip does ignore that sometimes. Maybe we will install a check to prevent those errors in the future.

Cheers, Max

On Tue, Jul 10, 2018 at 8:41 PM Naresh Rajendra Shah < notifications@github.com> wrote:

Recently faced this error. Could really use some help.

Keras version 2.1.6

AttributeError Traceback (most recent call last) in () ----> 1 analyzer_x = innvestigate.create_analyzer('gradient',k_model)

/usr/local/lib/python3.6/site-packages/innvestigate/analyzer/init.py in create_analyzer(name, model, kwargs) 87 :return: An instance of the chosen analyzer. 88 """ ---> 89 return analyzers[name](model, kwargs)

/usr/local/lib/python3.6/site-packages/innvestigate/analyzer/gradient_based.py in init(self, model, kwargs) 97 ] 98 ---> 99 super(Gradient, self).init(model, kwargs) 100 101 def _head_mapping(self, X):

/usr/local/lib/python3.6/site-packages/innvestigate/analyzer/base.py in init(self, model, reverse_verbose, reverse_clip_values, reverse_project_bottleneck_layers, reverse_check_min_max_values, reverse_check_finite, reverse_reapply_on_copied_layers, kwargs) 479 self._reverse_reapply_on_copied_layers = ( 480 reverse_reapply_on_copied_layers) --> 481 super(ReverseAnalyzerBase, self).init(model, kwargs) 482 483 def _gradient_reverse_mapping(

/usr/local/lib/python3.6/site-packages/innvestigate/analyzer/base.py in init(self, model, neuron_selection_mode, kwargs) 305 neuron_selection_mode="max_activation", 306 kwargs): --> 307 super(AnalyzerNetworkBase, self).init(model, **kwargs) 308 309 if neuron_selection_mode not in ["max_activation", "index", "all"]:

/usr/local/lib/python3.6/site-packages/innvestigate/analyzer/base.py in init(self, model, disable_model_checks) 84 85 checked = kgraph.model_contains(self._model, checks, ---> 86 return_only_counts=True) 87 tmp = zip(iutils.to_list(checked), messages, types) 88 for check_count, message, check_type in tmp:

/usr/local/lib/python3.6/site-packages/innvestigate/utils/keras/graph.py in model_contains(model, layer_condition, return_only_counts) 336 single_condition = False 337 --> 338 layers = get_model_layers(model) 339 collected_layers = [] 340 for condition in layer_condition:

/usr/local/lib/python3.6/site-packages/innvestigate/utils/keras/graph.py in get_model_layers(model) 324 if kchecks.is_network(layer): 325 collect_layers(layer) --> 326 collect_layers(model) 327 328 return ret

/usr/local/lib/python3.6/site-packages/innvestigate/utils/keras/graph.py in collect_layers(container) 322 assert layer not in ret 323 ret.append(layer) --> 324 if kchecks.is_network(layer): 325 collect_layers(layer) 326 collect_layers(model)

/usr/local/lib/python3.6/site-packages/innvestigate/utils/keras/checks.py in is_network(layer) 251 Is network in network? 252 """ --> 253 return isinstance(layer, keras.engine.topology.Network) 254 255

AttributeError: module 'keras.engine.topology' has no attribute 'Network'

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/albermax/innvestigate/issues/83, or mute the thread https://github.com/notifications/unsubscribe-auth/AMI3pyptvrosJdKpJbOb0eBhyWYA82XNks5uFPVjgaJpZM4VJ7Hx .

-- Cheers, Max