Code Monkey home page Code Monkey logo

hipsternet's Introduction

hipsternet

All the hipster things in Neural Net in a single repo: hipster optimization algorithms, hispter regularizations, everything!

Note, things will be added over time, so not all the hipsterest things will be here immediately. Also don't use this for your production code: use this to study and learn new things in the realm of Neural Net, Deep Net, Deep Learning, whatever.

What's in it?

Network Architectures

  1. Convolutional Net
  2. Feed Forward Net
  3. Recurrent Net
  4. LSTM Net
  5. GRU Net

Optimization algorithms

  1. SGD
  2. Momentum SGD
  3. Nesterov Momentum
  4. Adagrad
  5. RMSprop
  6. Adam

Loss functions

  1. Cross Entropy
  2. Hinge Loss
  3. Squared Loss
  4. L1 Regression
  5. L2 Regression

Regularization

  1. Dropout
  2. Your usual L1 and L2 regularization

Nonlinearities

  1. ReLU
  2. leaky ReLU
  3. sigmoid
  4. tanh

Hipster techniques

  1. BatchNorm
  2. Xavier weight initialization

Pooling

  1. Max pooling
  2. Average pooling

How to run this?

  1. Install miniconda http://conda.pydata.org/miniconda.html
  2. Do conda env create
  3. Enter the env source activate hipsternet
  4. [Optional] To install Tensorflow: chmod +x tensorflow.sh; ./tensorflow.sh
  5. Do things with the code if you want to
  6. To run the example:
  7. python run_mnist.py {ff|cnn}; cnn for convnet model, ff for the feed forward model
  8. python run_rnn.py {rnn|lstm|gru}; rnn for vanilla RNN model, lstm for LSTM net model, gru for GRU net model
  9. Just close the terminal if you done (or source deactivate, not a fan though)

What can I do with this?

Do anything you want. I licensed this with Unlicense License http://unlicense.org, as I need to take a break of using WTFPL license.

hipsternet's People

Contributors

wiseodd 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  avatar

hipsternet's Issues

l1_regression loss is calling regularization with reg_type='l2'

from hipsternet/hipsternet/loss.py line 112

def l1_regression(model, y_pred, y_train, lam=1e-3):
    m = y_pred.shape[0]

    data_loss = np.sum(np.abs(y_train - y_pred)) / m
    reg_loss = regularization(model, reg_type='l2', lam=lam)  #<----- should this be l1 not l2

    return data_loss + reg_loss

Shouldn't it be calling regularization with reg_type='l1' and not 'l2'?

No GPU support ?

I have tried the the codes in tf-gpu. But it doesnt seems to work !

Does it not support GPU computation ?

Contractive autoencoder is not working

Hello, I am just trying to implement the contractive autoencoder but everytime I try to run it shows me this error:

Epoch 1/3

RuntimeError Traceback (most recent call last)
in ()
----> 1 contractiveAutoencoder(X_train)

10 frames
/usr/local/lib/python3.7/dist-packages/tensorflow/python/framework/func_graph.py in wrapper(*args, **kwargs)
984 except Exception as e: # pylint:disable=broad-except
985 if hasattr(e, "ag_error_metadata"):
986 raise e.ag_error_metadata.to_exception(e)
987 else:
988 raise

RuntimeError: in user code:

/usr/local/lib/python3.7/dist-packages/tensorflow/python/keras/engine/training.py:855 train_function  *
    return step_function(self, iterator)
<ipython-input-5-80182a51a910>:15 contractive_loss  *
    W = tf.Variable(value=model.get_layer('encoded').get_weights()[0])  # N x N_hidden
/usr/local/lib/python3.7/dist-packages/tensorflow/python/keras/engine/base_layer.py:1831 get_weights  **
    return backend.batch_get_value(output_weights)
/usr/local/lib/python3.7/dist-packages/tensorflow/python/util/dispatch.py:206 wrapper
    return target(*args, **kwargs)
/usr/local/lib/python3.7/dist-packages/tensorflow/python/keras/backend.py:3746 batch_get_value
    raise RuntimeError('Cannot get value inside Tensorflow graph function.')

RuntimeError: Cannot get value inside Tensorflow graph function.

'

I have tried many things to resolve this issues but i am unable to. Let me know if there is any solution for this.

Unable to understand what to do with the output of im2col.py of this repo

Hello, I am trying to follow your im2col code. My intention is to do the forward pass of an RGB image without using any framework API. Right now I am using Keras.

I have started i the following way --

1/ Extract the weight from the model using layer.get_weights()
2/ Then I have appended the output of layer.get_weights() in a list named layerdic
3/ I have assigned an array conv_kernel and stored here the value of layerdic[0][0] and another array named conv_bias where I have stored layerdic[0][1]. If I am not wrong conv_kernel stores the value of kernel weight and conv_bias stores the bias value which I need for convolution.
4/ Then I have assigned an input image in X_test array and has done the convolution with your code.

My query is now ---

1/ What is the significance of out and cache and where do I need these values for the next part of forward pass?
1/ How can I do the next calculation. For example, in my case I will do the Flatten and Dense for classification. How can I approach for this purpose?

I am giving below my model:

    model = Sequential()

    model.add(Conv2D(1, (3, 3), padding='same',
                     input_shape=(3, IMG_SIZE, IMG_SIZE),
                     activation='relu'))
    model.add(Flatten())
    model.add(Dense(NUM_CLASSES, activation='softmax'))
    
    return model

model = cnn_model()

lr = 0.01
sgd = SGD(lr=lr, decay=1e-6, momentum=0.9, nesterov=True)
model.compile(loss='categorical_crossentropy',
          optimizer=sgd,
          metrics=['accuracy'])

Kindly please help me.

Pool layer problem

I think you have error in _pool_backward function at this place:

dX = dpool_fun(dX_col, dout_col, pool_cache)

You set dX which is not used later.

UPD: IT actually not critical since dX_col is changed internally. So this line can be changed on:

dpool_fun(dX_col, dout_col, pool_cache)

or

dX_col= dpool_fun(dX_col, dout_col, pool_cache)

im2col_indices method

How does this method work and do the 2D filtering? What is the name of this algorithm in algebra?

Thank you!

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.