Giter Club home page Giter Club logo

cs231n's People

Contributors

jinwoongkim avatar

Watchers

 avatar  avatar

cs231n's Issues

assignment1-2

svm_loss_naive

SVM loss function
image

for i in xrange(num_train):
   scores = X[i].dot(W) # scores to classes e.g., [ 3.2, 1.3, 2.2] for cat, car, frog
   score_yi = scores[y[i]] # score for input e.g., 3.2 if X[i] is cat
   for j in xrange(num_classes):
     if j == y[i]:
       continue
     loss += max(0,scores[j] - score_yi + 1) 

screen shot 2018-08-19 at 19 54 00
Link

 dW = np.zeros(W.shape) # initialize the gradient as zero
 # compute the loss and the gradient
 num_classes = W.shape[1]
 num_train = X.shape[0]
 loss = 0.0
 for i in xrange(num_train):
   scores = X[i].dot(W)
   score_yi = scores[y[i]]
   number_of_loss_contributor = 0
   for j in xrange(num_classes):
     if j == y[i]:
       continue
     margin = scores[j] - score_yi + 1 # note delta = 1
     if margin > 0:
       loss += margin
       dW[:, j] += X[i, :]
       number_of_loss_contributor += 1
   dW[:, y[i]] += (number_of_loss_contributor * -X[i])

 # Right now the loss is a sum over all training examples, but we want it
 # to be an average instead so we divide by num_train.
 loss /= num_train
 dW /= num_train

 # Add regularization to the loss.
 loss += reg * np.sum(W * W)
 dW += 2 * reg * W

 return loss, dW

screen shot 2018-08-19 at 20 11 38

screen shot 2018-08-19 at 20 03 12

assignment1-3

softmax_loss_naive

screen shot 2018-08-19 at 20 25 43

  loss = 0.0
  for i in xrange(num_train):
    scores = X[i].dot(W)
    score_yi = scores[y[i]]
    sum_esj = 0
    for j in xrange(num_classes):
      if j == y[i]:
        continue
      sum_esj += np.exp(scores[j])
    loss += np.log(np.exp(score_yi)/sum_esj)*-1

screen shot 2018-08-19 at 20 26 12

assignment1-4

My first try but it doesn't show correct numbers

    ### Compute the forward pass
    H1 = X@W1+b1
    H2 = H1@W2+b2
    print(H2)

image

then I read this architecture LOL

image

    ### Compute the forward pass
    H1 = np.maximum(0,X@W1+b1)
    H2 = H1@W2+b2
    print(H2)

Now it seems right :)

assignment1-1

Setting

After running jupyter notebook with knn.ipynb,
I faced an error as follows,

screen shot 2018-08-12 at 14 06 11

I solved this problem, by adding "backend: TkAgg" into ~/.matplotlib/matplotlibrc with below command,
echo "backend: TkAgg" >> ~/.matplotlib/matplotlibrc
and restart jupyter notebook.

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.