Giter VIP home page Giter VIP logo

Comments (5)

raghakot avatar raghakot commented on May 18, 2024

Can you post the full gist of your code for me to test?

from keras-vis.

zhangzhishan avatar zhangzhishan commented on May 18, 2024

@raghakot After I updated to the latest version of the code, I still get error https://pastebin.com/tqUSsQjg.
My full code is

layer_name = 'activation_5'
layer_idx = [idx for idx, layer in enumerate(model.layers) if layer.name == layer_name][0]
# Here we are asking it to show attention such that prob of `pred_class` is maximized.
layer_output = model.layers[layer_idx].output
# print layer_output[:, 0]
heatmap = visualize_saliency(model, layer_idx, [pred_class], x)

My model struct is

[{'class_name': 'Conv1D', 'config': {'kernel_initializer': {'class_name': 'VarianceScaling', 'config': {'distribution': 'uniform', 'scale': 1.0, 'seed': None, 'mode': 'fan_avg'}}, 'name': u'convolution1d_1', 'kernel_constraint': None, 'bias_regularizer': None, 'bias_constraint': None, 'dtype': u'float32', 'activation': 'linear', 'trainable': True, 'filters': 32, 'padding': u'same', 'strides': (1,), 'dilation_rate': (1,), 'kernel_regularizer': None, 'bias_initializer': {'class_name': 'Zeros', 'config': {}}, 'batch_input_shape': (None, 1, 401), 'use_bias': True, 'activity_regularizer': None, 'kernel_size': (3,)}}, {'class_name': 'Activation', 'config': {'activation': 'relu', 'trainable': True, 'name': u'activation_1'}}, {'class_name': 'MaxPooling1D', 'config': {'padding': u'same', 'strides': (2,), 'trainable': True, 'name': u'maxpooling1d_1', 'pool_size': (2,)}}, {'class_name': 'Conv1D', 'config': {'kernel_initializer': {'class_name': 'VarianceScaling', 'config': {'distribution': 'uniform', 'scale': 1.0, 'seed': None, 'mode': 'fan_avg'}}, 'name': u'convolution1d_2', 'kernel_constraint': None, 'bias_regularizer': None, 'bias_constraint': None, 'dtype': 'float32', 'activation': 'linear', 'trainable': True, 'filters': 32, 'padding': u'same', 'strides': (1,), 'dilation_rate': (1,), 'kernel_regularizer': None, 'bias_initializer': {'class_name': 'Zeros', 'config': {}}, 'batch_input_shape': (None, None, None), 'use_bias': True, 'activity_regularizer': None, 'kernel_size': (3,)}}, {'class_name': 'Activation', 'config': {'activation': 'relu', 'trainable': True, 'name': u'activation_2'}}, {'class_name': 'MaxPooling1D', 'config': {'padding': u'same', 'strides': (2,), 'trainable': True, 'name': u'maxpooling1d_2', 'pool_size': (2,)}}, {'class_name': 'Conv1D', 'config': {'kernel_initializer': {'class_name': 'VarianceScaling', 'config': {'distribution': 'uniform', 'scale': 1.0, 'seed': None, 'mode': 'fan_avg'}}, 'name': u'convolution1d_3', 'kernel_constraint': None, 'bias_regularizer': None, 'bias_constraint': None, 'dtype': 'float32', 'activation': 'linear', 'trainable': True, 'filters': 64, 'padding': u'same', 'strides': (1,), 'dilation_rate': (1,), 'kernel_regularizer': None, 'bias_initializer': {'class_name': 'Zeros', 'config': {}}, 'batch_input_shape': (None, None, None), 'use_bias': True, 'activity_regularizer': None, 'kernel_size': (3,)}}, {'class_name': 'Activation', 'config': {'activation': 'relu', 'trainable': True, 'name': u'activation_3'}}, {'class_name': 'MaxPooling1D', 'config': {'padding': u'same', 'strides': (2,), 'trainable': True, 'name': u'maxpooling1d_3', 'pool_size': (2,)}}, {'class_name': 'Flatten', 'config': {'trainable': True, 'name': u'flatten_1'}}, {'class_name': 'Dense', 'config': {'kernel_initializer': {'class_name': 'VarianceScaling', 'config': {'distribution': 'uniform', 'scale': 1.0, 'seed': None, 'mode': 'fan_avg'}}, 'name': u'dense_1', 'kernel_constraint': None, 'bias_regularizer': None, 'bias_constraint': None, 'dtype': 'float32', 'activation': 'linear', 'trainable': True, 'kernel_regularizer': None, 'bias_initializer': {'class_name': 'Zeros', 'config': {}}, 'units': 64, 'batch_input_shape': (None, 64), 'use_bias': True, 'activity_regularizer': None}}, {'class_name': 'Activation', 'config': {'activation': 'relu', 'trainable': True, 'name': u'activation_4'}}, {'class_name': 'Dropout', 'config': {'rate': 0.5, 'trainable': True, 'name': u'dropout_1'}}, {'class_name': 'Dense', 'config': {'kernel_initializer': {'class_name': 'VarianceScaling', 'config': {'distribution': 'uniform', 'scale': 1.0, 'seed': None, 'mode': 'fan_avg'}}, 'name': u'dense_2', 'kernel_constraint': None, 'bias_regularizer': None, 'bias_constraint': None, 'dtype': 'float32', 'activation': 'linear', 'trainable': True, 'kernel_regularizer': None, 'bias_initializer': {'class_name': 'Zeros', 'config': {}}, 'units': 1, 'batch_input_shape': (None, 64), 'use_bias': True, 'activity_regularizer': None}}, {'class_name': 'Activation', 'config': {'activation': 'sigmoid', 'trainable': True, 'name': u'activation_5'}}]

The last layer is activation_5 using sigmoid activation function.

from keras-vis.

raghakot avatar raghakot commented on May 18, 2024

This should now work. Can you try again?

from keras-vis.

raghakot avatar raghakot commented on May 18, 2024

Closing. Feel free to open if this is still an issue.

from keras-vis.

nassarofficial avatar nassarofficial commented on May 18, 2024

Hello, I'm having the same problem with a different model. Here is my model: https://gist.github.com/nassarofficial/ff2ca99114b2a4a9e07d336fe64dce71

from keras-vis.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.