GithubHelp home page GithubHelp logo

syyunn / grad-cam-text Goto Github PK

View Code? Open in Web Editor NEW

This project forked from haebinshin/grad-cam-text

0.0 2.0 0.0 141 KB

Implementation of Grad-CAM for text.

Python 37.65% Jupyter Notebook 62.02% Shell 0.33%

grad-cam-text's Introduction

Grad-CAM for Text

This is implementation of Grad-CAM for text classification model. The model used is 1D-CNN for text classification which was introduced in Yoon Kim (2014). The data used are re-fined version of Stanford Sentimental Treebank which re-labeled for binary classification. Input feature is slim version of word2vec.

It especially requires python >= 3, tensorflow >= 1.4 (tf.data.Dataset, tf.estimator.Estimator).

Installation

>>> pip3 install -r requirements.txt

Feature

Before training, it requires word2vec binary file. Download by word2vec.sh, it will download in directory word2vec/.

>>> ./word2vec.sh

All word2vec binary have to be located on word2vec/ directory.

  • word2vec/GoogleNews-vectors-negative300-SLIM.bin

Stanford Sentimental Treebank Dataset(SST) will be download automatically when training.

Training

usage: train.py [-h] [--epoch EPOCH] [--batch-size BATCH_SIZE]
                [--learning-rate LEARNING_RATE] [--gpu-index GPU_INDEX]

optional arguments:
  -h, --help            show this help message and exit
  --epoch EPOCH         Train Epoch
  --batch-size BATCH_SIZE
                        Train Batch Size
  --learning-rate LEARNING_RATE
                        Train Learning Rate
  --gpu-index GPU_INDEX
                        GPU Index Number

Visulization

It shows which word impacts the result with heatmap of sentence. Strong impact factor gets brighter color, otherwise darker color.

Fill CKPT variable with your ckeckpoint path in visualize.ipynb.

grad-cam-text's People

Contributors

syyunn avatar haebinshin avatar

Watchers

James Cloos avatar paper2code - bot avatar

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.