Code Monkey home page Code Monkey logo

cs231's Issues

Assignment 1, kNN classifier

Mahan,

I think I have found an error in the k-fold cross validation snippet of the knn jupyter notebook. In the second segment of this snippet, the line:
train_set = np.concatenate((X_train_folds[:i] + X_train_folds[i+1:]))

I believe that using the "+" operator on these two arrays (X_train_folds[:i] & X_train_folds[i+1:]) will actually add together the array elements instead of concatenating them as you intended. Do you agree with this?

In my own implementation I have the following (the reason for the if-elif-else is that concatenating an empty array gives an error):
if i == 0:
X_train_fold = np.concatenate(X_train_folds[(i + 1):num_folds])
y_train_fold = np.concatenate(y_train_folds[(i + 1):num_folds])
elif i == (num_folds - 1):
X_train_fold = np.concatenate(X_train_folds[0:i])
y_train_fold = np.concatenate(y_train_folds[0:i])
else:
X_train_fold = np.concatenate((np.concatenate(X_train_folds[0:i]), np.concatenate(X_train_folds[(i + 1):num_folds])))
y_train_fold = np.concatenate((np.concatenate(y_train_folds[0:i]), np.concatenate(y_train_folds[(i + 1):num_folds])))
classifier.train(X_train_fold, y_train_fold)

I am open to suggestions on a cleaner way to implement this...

Your feedback is greatly appreciated -- I don't have someone to discuss this type of thing with....

Regards,
True

L2 regularization for the gradient

hello,

I just wonder whether the L2 regularization for gradient should also be considered in the third question of NetworkVisualization-TensorFlow. Otherwise, the variable Xi remains unused. The computed gradient should be like dx[0] - 2 * l2_reg * Xi instead of dx[0]

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.