【发布时间】:2016-09-08 21:16:28
【问题描述】:
我目前正在通过 theano tutorial 进行逻辑回归,非常类似于这篇文章中讨论的内容:
what-does-negative-log-likelihood-of-logistic-regression-in-theano-look-like。但是,原来的tutorial 使用共享变量 W 和b,以及一个称为输入 的矩阵。输入是n x n_in 矩阵,W 是n_in x n_out,b 是n_out x 1 列向量。
self.W = theano.shared(
value=numpy.zeros(
(n_in, n_out),
dtype=theano.config.floatX
),
name='W',
borrow=True
)
self.b = theano.shared(
value=numpy.zeros(
(n_out,),
dtype=theano.config.floatX
),
name='b',
borrow=True
)
self.p_y_given_x = T.nnet.softmax(T.dot(input, self.W) + self.b)
现在,据我从共享变量的文档中了解到,共享变量的广播模式默认为 false。那为什么这行代码没有因为尺寸不匹配而抛出错误呢?
self.p_y_given_x = T.nnet.softmax(T.dot(input, self.W) + self.b)
毕竟,我们将矩阵T.dot(input, self.W) 添加到向量b。毕竟默认情况下共享变量会广播吗?即使有广播,维度也不会加起来。 T.dot(input, self.W) 是 n x n_out 矩阵和 b 是 n_out x 1 向量。
我错过了什么?
【问题讨论】:
标签: theano