0
令人費解的語法我跟着教程logistic with theano與theano
import numpy
import theano
import theano.tensor as T
rng = numpy.random
N = 400 # training sample size
feats = 784 # number of input variables
# initialize the 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 that target = 1
prediction = p_1 > 0.5 # The 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()# The cost to minimize
gw, gb = T.grad(cost, [w, b]) # Compute the gradient of the cost
# w.r.t weight vector w and
# bias term b
# (we shall return to this in a
# following section of this tutorial)
,但我不知道代碼 「預測= P_1> 0.5」。當p_1> 0.5時, ,prediction = True?要不然 ?
我會說:「邏輯上等同於,但遠遠超過更具可讀性」。 – Malvolio
@Malvolio:對於尚未理解其含義的初學者來說,這不是真的。當OP需要提出這個問題時,OP的閱讀停頓了一下:) –
@DanCornilescu - 「可讀」並不意味着「對尚未理解語言的人可讀」。 – Malvolio