BrainJS / BrainJS/brain.js

LSTM - Doing my own version of `words2vec` - how do I get *hidden* outputs?

Open
#208 15 comments 0 reactions 1 assignee Claimed by @robertleeplummerjr View on GitHub
in progress
Dominant language
TypeScript
Stars
14.9k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

Pretty picture:
![image](https://user-images.githubusercontent.com/4821548/39978633-b1bce59c-570f-11e8-904a-8c12838434b8.png)

Based [on this article [1]](https://towardsdatascience.com/word2vec-a-baby-step-in-deep-learning-but-a-giant-leap-towards-natural-language-processing-40fe4e8602ba), the words2vec algo basically trains an LSTM to predict a word given the context, then (here's the key part for me), to get the vector for a given word, they feed to word to the trained LSTM model and take the output "at the hidden layer [as] the ‘word embedding’ of the input word."

My question therefore is, how can I get the "output at the hidden layer" of my lovely trained LSTM?

And WHY would I even want to do this? Well, my application has nothing to do with words, but still has to do with comparing contexts. I have a sequence of actions - for example, potty training a pet: "Wine" -> "Go Outside" -> "Go Potty" -> "Come Inside" -> "Get Rewarded". My hope is to be able to train the LSTM to predict the next action - great, lovely. But what I really want is to get the "vector embedding" of the input action - a vector representing the action, like words2vec has vectors representing words. Hence my desire to get the output at the hidden layer of the LSTM.

Dooable - yay/nay?

[1] Reference article: https://towardsdatascience.com/word2vec-a-baby-step-in-deep-learning-but-a-giant-leap-towards-natural-language-processing-40fe4e8602ba

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.