• Stars
    star
    5,635
  • Rank 7,245 (Top 0.2 %)
  • Language
    Python
  • License
    Apache License 2.0
  • Created about 9 years ago
  • Updated 8 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Convolutional Neural Network for Text Classification in Tensorflow

This code belongs to the "Implementing a CNN for Text Classification in Tensorflow" blog post.

It is slightly simplified implementation of Kim's Convolutional Neural Networks for Sentence Classification paper in Tensorflow.

Requirements

  • Python 3
  • Tensorflow > 0.12
  • Numpy

Training

Print parameters:

./train.py --help
optional arguments:
  -h, --help            show this help message and exit
  --embedding_dim EMBEDDING_DIM
                        Dimensionality of character embedding (default: 128)
  --filter_sizes FILTER_SIZES
                        Comma-separated filter sizes (default: '3,4,5')
  --num_filters NUM_FILTERS
                        Number of filters per filter size (default: 128)
  --l2_reg_lambda L2_REG_LAMBDA
                        L2 regularizaion lambda (default: 0.0)
  --dropout_keep_prob DROPOUT_KEEP_PROB
                        Dropout keep probability (default: 0.5)
  --batch_size BATCH_SIZE
                        Batch Size (default: 64)
  --num_epochs NUM_EPOCHS
                        Number of training epochs (default: 100)
  --evaluate_every EVALUATE_EVERY
                        Evaluate model on dev set after this many steps
                        (default: 100)
  --checkpoint_every CHECKPOINT_EVERY
                        Save model after this many steps (default: 100)
  --allow_soft_placement ALLOW_SOFT_PLACEMENT
                        Allow device soft device placement
  --noallow_soft_placement
  --log_device_placement LOG_DEVICE_PLACEMENT
                        Log placement of ops on devices
  --nolog_device_placement

Train:

./train.py

Evaluating

./eval.py --eval_train --checkpoint_dir="./runs/1459637919/checkpoints/"

Replace the checkpoint dir with the output from the training. To use your own data, change the eval.py script to load your data.

References

More Repositories

1

reinforcement-learning

Implementation of Reinforcement Learning Algorithms. Python, OpenAI Gym, Tensorflow. Exercises and Solutions to accompany Sutton's Book and David Silver's course.
Jupyter Notebook
20,284
star
2

deeplearning-papernotes

Summaries and notes on Deep Learning research papers
4,385
star
3

nn-from-scratch

Implementing a Neural Network from Scratch
Jupyter Notebook
1,811
star
4

chatbot-retrieval

Dual LSTM Encoder for Dialog Response Generation
Jupyter Notebook
1,579
star
5

neal-react

Startup Landing Page Components for React.js
JavaScript
1,378
star
6

rnn-tutorial-rnnlm

Recurrent Neural Network Tutorial, Part 2 - Implementing a RNN in Python and Theano
Jupyter Notebook
891
star
7

rails_startup_template

A startup template for Ruby on Rails 4 applications
Ruby
668
star
8

rnn-tutorial-gru-lstm

Language Model GRU with Python and Theano
Python
492
star
9

tf-rnn

Practical Examples for RNNs in Tensorflow
Jupyter Notebook
484
star
10

startupreadings

Reading list for all things startup-related
423
star
11

papergraph

AI/ML citation graph with postgres + graphql
Jupyter Notebook
188
star
12

booknotes

Notes I'm taking when reading books
137
star
13

neal-sample

Sample page for neal-react
JavaScript
69
star
14

nn-theano

Speed up your Neural Network with Theano and the GPU
Python
61
star
15

bella

Labeling and Evaluation Tool for NLP Tasks
JavaScript
55
star
16

papergraph-ui

Browse the CS/AI/ML research paper graph
Svelte
52
star
17

sentiment-analysis

Japanese Sentiment Analysis
Jupyter Notebook
42
star
18

deepdive

Scala
36
star
19

akka-cluster-deploy

Akka cluster + Docker + CoreOS
Scala
26
star
20

url-metadata-extractor

API that extracts metadata from a URL.
HTML
26
star
21

linkedin-extractor

Given a Linkedin profie URL returns structured metadata.
HTML
25
star
22

representation-learning

Unsupervised Deep Learning and Representation Learning Tutorial
Jupyter Notebook
12
star
23

pandoc-graphql

Turn your local documents into a GraphQL API using pandoc
Rust
12
star
24

ablog-content

Jupyter Notebook
9
star
25

probability-monads

Haskell
9
star
26

s3-cors-upload-rails

Ruby
8
star
27

visual-pagedump

An API to create visual-semantic mappings between web pages and DOM nodes
JavaScript
6
star
28

boilerpipe-api

Extract main article text from HTML pages
Scala
5
star
29

elk-playground

Playground for Elasticsearch, Logstash and Kibana using Docker
Shell
5
star
30

scpd-downloader

Stanford SCPD Lecture Downloader
Ruby
4
star
31

twitter-collect

Monitors Twitter for interesting articles
JavaScript
3
star
32

crawler-scala

Scala
2
star
33

hndump

Watches HackerNews and dumps raw events for later analysis.
JavaScript
1
star
34

sampler

Gibbs sampler for factor graphs
Scala
1
star
35

rnn-bptt

Latex files for RNN BPTT post
TeX
1
star
36

rust-analyzer-issue3667

Rust
1
star
37

phonenumber-api

Extracts phone numbers from raw text
Scala
1
star
38

twitter-smileys

Crawling twitter for smiley distant supervision
TeX
1
star
39

actioncrawler

Crawling wrapper for webdriver
JavaScript
1
star
40

lang_classifier

Python language classifier
Python
1
star