Comments (5)
Can you post the full gist of your code for me to test?
from keras-vis.
@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.
This should now work. Can you try again?
from keras-vis.
Closing. Feel free to open if this is still an issue.
from keras-vis.
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)
- [question] electrode contribution in EEG input
- Is there any reason why no demo for activation maximization for resnet?
- Is the project still maintained? HOT 2
- Exact gradient values
- Memory increases and iterations slow down while using visualize_saliency
- 3D MRI Image
- How to clip the positive gradients when using visualization_cam?
- AttributeError: module 'tensorflow' has no attribute 'get_default_graph' HOT 1
- AttributeError: 'list'/integer/float object has no attribute 'build_loss' in visualize_saliency_with_losses
- ImportError: cannot import name '_Conv' from 'keras.layers.convolutional' HOT 19
- Generated Image Color
- Issue - "ImportError: cannot import name '_Conv' from 'keras.layers.convolutional'" HOT 2
- Tensorflow version? HOT 1
- Problem with custom CNN VGG16 (unsupported operand type(s) for *: 'int' and 'NoneType')
- scipy 1.5.2 ImportError: cannot import name 'imresize' HOT 3
- Cannot convert a symbolic Keras input/output to a numpy array... HOT 1
- v
- Is this also working for Faster R-CNN or Mask R-CNN?
- Why is pre-activation output used for computing vanilla saliency map?
- AttributeError: module 'keras.utils.generic_utils' has no attribute 'populate_dict_with_module_objects'
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from keras-vis.