Skip to content

Instantly share code, notes, and snippets.

@omitevski
Created December 12, 2010 17:23
Show Gist options
  • Save omitevski/738193 to your computer and use it in GitHub Desktop.
Save omitevski/738193 to your computer and use it in GitHub Desktop.
first and last layer
######
#It uses the cross entropy error function:
f = -(1/batchSize)*sum(data*log(recon) + (1-data)*log(1-recon))
#compute derivatives for the last layer
Ix_n2 = (1/float(batchSize))*(recon-data)
# outer product
# w_n2_probs the outputs at the layer before the last
dwLast = dot(w_n2_probs.t, Ix_n2)
# compute derivatives for the first layer
# w1probs are the outputs at the first layer
# w1 the weights of the first layer
#
Ix1 = dot(w1, Ix2.t).t
Ix1 = Ix1*w1probs*(1-w1probs)
Ix1 = Ix1[:,0:-1]
data = c_[data, ones(batchSize)]
# outer product
w1 = dot(data.t, Ix1)
#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment