All Projects → po3rin → gonnp

po3rin / gonnp

Licence: other
📉Deep learning from scratch using Go. Specializes in natural language processing

Programming Languages

go
31211 projects - #10 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to gonnp

word2vec-pytorch
Extremely simple and fast word2vec implementation with Negative Sampling + Sub-sampling
Stars: ✭ 145 (+457.69%)
Mutual labels:  word2vec
sarcasm-detection-for-sentiment-analysis
Sarcasm Detection for Sentiment Analysis
Stars: ✭ 21 (-19.23%)
Mutual labels:  word2vec
word2vec-from-scratch-with-python
A very simple, bare-bones, inefficient, implementation of skip-gram word2vec from scratch with Python
Stars: ✭ 85 (+226.92%)
Mutual labels:  word2vec
textaugment
TextAugment: Text Augmentation Library
Stars: ✭ 280 (+976.92%)
Mutual labels:  word2vec
NLP-paper
🎨 🎨NLP 自然语言处理教程 🎨🎨 https://dataxujing.github.io/NLP-paper/
Stars: ✭ 23 (-11.54%)
Mutual labels:  word2vec
word2vec
Rust interface to word2vec.
Stars: ✭ 22 (-15.38%)
Mutual labels:  word2vec
Name-disambiguation
同名论文消歧的工程化方案(参考2019智源-aminer人名消歧竞赛第一名方案)
Stars: ✭ 17 (-34.62%)
Mutual labels:  word2vec
doc2vec-golang
doc2vec , word2vec, implemented by golang. word embedding representation
Stars: ✭ 33 (+26.92%)
Mutual labels:  word2vec
revery
A personal semantic search engine capable of surfacing relevant bookmarks, journal entries, notes, blogs, contacts, and more, built on an efficient document embedding algorithm and Monocle's personal search index.
Stars: ✭ 200 (+669.23%)
Mutual labels:  word2vec
NLP PEMDC
NLP Predtrained Embeddings, Models and Datasets Collections(NLP_PEMDC). The collection will keep updating.
Stars: ✭ 58 (+123.08%)
Mutual labels:  word2vec
word-benchmarks
Benchmarks for intrinsic word embeddings evaluation.
Stars: ✭ 45 (+73.08%)
Mutual labels:  word2vec
Arabic-Word-Embeddings-Word2vec
Arabic Word Embeddings Word2vec
Stars: ✭ 26 (+0%)
Mutual labels:  word2vec
test word2vec uyghur
Bu Uyghur yéziqini Pythonning gensim ambiridiki word2vec algorizimida sinap baqqan misal.
Stars: ✭ 15 (-42.31%)
Mutual labels:  word2vec
word2vec-on-wikipedia
A pipeline for training word embeddings using word2vec on wikipedia corpus.
Stars: ✭ 68 (+161.54%)
Mutual labels:  word2vec
Word2VecJava
Word2Vec In Java (2013 google word2vec opensource)
Stars: ✭ 13 (-50%)
Mutual labels:  word2vec
img classification deep learning
No description or website provided.
Stars: ✭ 19 (-26.92%)
Mutual labels:  word2vec
text-classification-cn
中文文本分类实践,基于搜狗新闻语料库,采用传统机器学习方法以及预训练模型等方法
Stars: ✭ 81 (+211.54%)
Mutual labels:  word2vec
navec
Compact high quality word embeddings for Russian language
Stars: ✭ 118 (+353.85%)
Mutual labels:  word2vec
word2vec
Use word2vec to improve search result
Stars: ✭ 63 (+142.31%)
Mutual labels:  word2vec
wmd4j
wmd4j is a Java library for calculating Word Mover's Distance (WMD)
Stars: ✭ 31 (+19.23%)
Mutual labels:  word2vec

gonnp

Deep learning from scratch using Go. Specializes in natural language processing


CircleCI GolangCI Go Report Card codecov GoDoc

What

Package gonnp is the library of neural network components specialized in natural language processing in Go. You can assemble a neural network with the necessary components.

Dependencies

This component depends on gonum.org/v1/gonum/mat https://github.com/gonum/gonum/

Components

The number of components will increase in the future.

Layers

  • Affine
  • MatuMul
  • Embedding
  • EmbeddingDot
  • Relu
  • Sigmoid
  • Softmax with Loss
  • Sigmoid with Loss

Optimizer

  • SDG
  • Adam

Sampler

Unigram Sampler

Directory

.
├── layers ---( Package layers impliments various layer for neural network. )
├── matutil ---( Package matutil has utility functions of gonum matrix. )
├── models ---( Package models has some of neural netwark models. )
├── optimizers ---( Package optimizers updates prams (ex. weight, bias ...) using various algorism. )
├── params ---( Package params has common parametors type. )
├── store ---( Package store lets you to store trained data. )
├── testdata
│   ├── ptb ---( Package ptb provides load PTB data functions. )
├── trainer ---( Package trainer impliments shorhand of training for deep lerning. )
└── word ---( Package word is functions of text processing. )

Example

Word2Vec

with EmbeddingDot Layers & Negative Sampling

package e2e_test

import (
	"fmt"
	"io/ioutil"
	"log"
	"os"

	"github.com/po3rin/gonnp/matutil"
	"github.com/po3rin/gonnp/models"
	"github.com/po3rin/gonnp/optimizers"
	"github.com/po3rin/gonnp/trainer"
	"github.com/po3rin/gonnp/word"
)

func main() {
	windowSize := 5
	hiddenSize := 100
	batchSize := 100
	maxEpoch := 10

        // prepare one-hot matrix from text data.
	file, err := os.Open("../testdata/golang.txt")
	if err != nil {
		log.Fatal(err)
	}
	defer file.Close()
	text, err := ioutil.ReadAll(file)
	if err != nil {
		log.Fatal(err)
	}
	corpus, w2id, id2w := word.PreProcess(string(text))
	vocabSize := len(w2id)
	contexts, target := word.CreateContextsAndTarget(corpus, windowSize)

        // Inits model
        model := models.InitCBOW(vocabSize, hiddenSize, windowSize, corpus)
        // choses optimizer
        optimizer := optimizers.InitAdam(0.001, 0.9, 0.999)
        // inits trainer with model & optimizer.
        trainer := trainer.InitTrainer(model, optimizer)

        // training !!
        trainer.Fit(contexts, target, maxEpoch, batchSize)

        // checks outputs
	dist := trainer.GetWordDist()
	w2v := word.GetWord2VecFromDist(dist, id2w)
	for w, v := range w2v {
		fmt.Printf("=== %v ===\n", w)
		matutil.PrintMat(v)
	}
}

outputs

=== you ===
⎡ -0.983712641282964⎤
⎢ 0.9633828650811918⎥
⎢-0.7253396760955725⎥
⎢-0.9927919148802162⎥
    .
    .
    .

MNIST

package main

import (
        "github.com/po3rin/gomnist"
        "github.com/po3rin/gonnp/models"
        "github.com/po3rin/gonnp/optimizers"
        "github.com/po3rin/gonnp/trainer"
)

func main() {
        model := models.NewTwoLayerNet(784, 100, 10)
        optimizer := optimizers.InitSDG(0.01)
        trainer := trainer.InitTrainer(model, optimizer, trainer.EvalInterval(20))

        // load MNIST data using github.com/po3rin/gomnist package
        l := gomnist.NewLoader("./../testdata", gomnist.OneHotLabel(true), gomnist.Normalization(true))
        mnist, _ := l.Load()

        trainer.Fit(mnist.TestData, mnist.TestLabels, 10, 100)
}

Reference

https://github.com/oreilly-japan/deep-learning-from-scratch-2

TODO

  • Impliments RNN
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].