python - puzzling syntax with theano -


i followed tutorial logistic theano

import numpy import theano import theano.tensor t rng = numpy.random  n = 400                                   # training sample size feats = 784                               # number of input variables    # initialize bias term b = theano.shared(0., name="b")  print("initial model:") print(w.get_value()) print(b.get_value())  # construct theano expression graph p_1 = 1 / (1 + t.exp(-t.dot(x, w) - b))   # probability target = 1 prediction = p_1 > 0.5                    # prediction thresholded xent = -y * t.log(p_1) - (1-y) * t.log(1-p_1) # cross-entropy loss function cost = xent.mean() + 0.01 * (w ** 2).sum()# cost minimize gw, gb = t.grad(cost, [w, b])             # compute gradient of cost                                       # w.r.t weight vector w ,                                       # bias term b                                       # (we shall return in                                       # following section of tutorial) 

but don't know code " prediction = p_1 > 0.5 " . when p_1 > 0.5 ,prediction = true ? or else ?

yes, saying prediction = p_1 > 0.5 equivalent to:

if p_1 > 0.5:     prediction = true else:     prediction = false 

Comments

Popular posts from this blog

Django REST Framework perform_create: You cannot call `.save()` after accessing `serializer.data` -

Why does Go error when trying to marshal this JSON? -