Code Monkey home page Code Monkey logo

hipsternet's Issues

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.

im2col_indices method

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

Thank you!

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.

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'?

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)

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.