cs231n's People
cs231n's Issues
assignment1-5
assignment1-2
svm_loss_naive
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)
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
assignment1-3
assignment1-4
assignment1-1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.