explaingit

dennybritz/cnn-text-classification-tf

5,685PythonAudience · researcherComplexity · 3/5Setup · hard

TLDR

A Python implementation of a convolutional neural network that sorts text into categories, based on a 2014 research paper, built with TensorFlow as a clean reference for learning text classification.

Mindmap

mindmap
  root((cnn-text-tf))
    What it does
      Text classification
      CNN for NLP
      Category prediction
    Tech stack
      Python
      TensorFlow
      NumPy
    Use cases
      Sentiment analysis
      Topic sorting
      Research reference
    Audience
      ML researchers
      Students
      Data practitioners
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Train a model to classify movie reviews as positive or negative using the included example dataset.

USE CASE 2

Adapt the training script to sort support tickets by topic using your own labeled text data.

USE CASE 3

Use the codebase as a readable reference for understanding how convolutional neural networks process text.

USE CASE 4

Run the evaluation script to measure how accurately your trained model performs on held-out examples.

Tech stack

PythonTensorFlowNumPy

Getting it running

Difficulty · hard Time to first run · 1h+

Targets an older TensorFlow version from 2015, requires matching the correct TensorFlow and Python versions before training will run.

No explicit license was mentioned in the explanation.

In plain English

This repository is a Python implementation of a specific machine learning technique for sorting text into categories. The technique, called a convolutional neural network, was described in a 2014 academic paper by Yoon Kim, and this code is a simplified version of that paper's approach, built using TensorFlow. It was created as companion code for a blog post on the site WildML. The idea behind text classification is to train a program to read a piece of text and decide what category it belongs to. For example, you could teach it to label movie reviews as positive or negative, or sort support tickets by topic. The model learns by reading many examples, finding patterns in the words, and adjusting itself until it gets good at making those judgments. To use this code, you run a training script that feeds it data and produces a saved model. There are several settings you can adjust before training, like how many passes to make over the data, how large to make the batches of examples processed at once, and how aggressively to apply regularization (a technique that helps the model avoid memorizing the training data too closely). Once training finishes, a separate evaluation script lets you test how well the resulting model performs. The repository is fairly minimal in scope. It does not include a graphical interface or a hosted demo. Using it requires some comfort with running Python scripts from a terminal, managing dependencies like TensorFlow and Numpy, and preparing your own text dataset if you want to classify something beyond the default example data. This code dates from 2015 and targets an older version of TensorFlow. Researchers and students studying the foundations of text classification models still find it useful as a clean, readable reference for how this type of neural network is structured.

Copy-paste prompts

Prompt 1
I want to train cnn-text-classification-tf on my own dataset of customer feedback. Show me how to format my data and which script flags to change.
Prompt 2
Walk me through what each layer in the CNN text classifier does so I can explain it to a non-technical stakeholder.
Prompt 3
How do I adjust the regularization strength and batch size in cnn-text-classification-tf to reduce overfitting on a small dataset?
Prompt 4
Show me how to load a trained cnn-text-classification-tf model and run inference on a single new text string.
Prompt 5
What changes would I need to make to cnn-text-classification-tf to handle multi-label classification instead of single-category output?
Open on GitHub → Explain another repo

← dennybritz on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.