Coder Social home page Coder Social logo

suriyadeepan / rnn-from-scratch Goto Github PK

View Code? Open in Web Editor NEW
127.0 12.0 55.0 1.54 MB

Use tensorflow's tf.scan to build vanilla, GRU and LSTM RNNs

License: GNU General Public License v3.0

Python 100.00%
tensorflow rnn recurrent-neural-networks language-modeling

rnn-from-scratch's People

Contributors

suriyadeepan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rnn-from-scratch's Issues

UnicodeDecodeError in data.py

UnicodeDecodeError: 'cp949' codec can't decode byte 0xe2 in position 9290: illegal multibyte sequence

Hi, I am following your vanilla RNN code. and I encounter an error above.
so, goggled and found the solution below.

  • encoded file via 'cp949' makes this error sometimes
  • fyi, I use anaconda, python 3, in windows 7
# line 25 of data.py
def read_lines(filename):
    #with open(filename) as f:
    with open(filename, 'rt', encoding='UTF8') as f:
        return f.read().split('\n')

Adapting your single-layer LSTM model for binary classification

Hello, thanks for making this code available. It's useful because I'm trying to create a custom, LSTM cell (with additional logic for the "forget" gate), and you've clearly coded out the internal logic of the cell.

This isn't so much an issue on the repo I'm writing about. I'm wondering if you could explain and possibly show how to adapt the model for predicting a binary outcome. Let's say the new outcome variable is made like this:

from sklearn.preprocessing import OneHotEncoder, LabelBinarizer, LabelEncoder

_, Y = make_classification(n_samples = 118929, n_classes = 2, n_features=2, n_redundant=0, n_informative=1, n_clusters_per_class=1)
label_encoder = LabelEncoder()
integer_encoded = label_encoder.fit_transform(Y)
onehot_encoder = OneHotEncoder(sparse=False)
integer_encoded = integer_encoded.reshape(len(integer_encoded), 1)
onehot_encoded = onehot_encoder.fit_transform(integer_encoded)
Y = onehot_encoded

I feel very close but I'm getting errors here: tf.nn.sparse_softmax_cross_entropy_with_logits(logits=logits, labels=ys_)

Thank you!

if tf.scan version is faster??

Thanks for the tutorial code. I wonder if the tf.scan version of a recurrent network is faster than its RNN implementation?

input gate should use tanh for activation

thanks for this awesome implementation.

fyi, the input gate i = tf.sigmoid(tf.matmul(x,U[0]) + tf.matmul(st_1,W[0])) typically uses tanh as the activation function (unlike other gates, which should use sigmoid).

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.