问题描述
Andrew Ng在ML上进行MOOC时,他从理论上解释了 theta'* X
给了我们假设,而在做功课时,我们使用了 theta * X
.为什么会这样呢?
While doing MOOC on ML by Andrew Ng, he in theory explains theta'*X
gives us hypothesis and while doing coursework we use theta*X
. Why it's so?
推荐答案
在数学中,向量"始终定义为垂直堆叠的数组,例如,并表示3中的单点维空间.
In mathematics, a 'vector' is always defined as a vertically-stacked array, e.g. , and signifies a single point in a 3-dimensional space.
水平"向量通常表示一系列观察结果,例如是3个标量观测值的元组.
A 'horizontal' vector, typically signifies an array of observations, e.g. is a tuple of 3 scalar observations.
同样,矩阵可以被认为是向量的集合.例如,以下是四个3维向量的集合:
Equally, a matrix can be thought of as a collection of vectors. E.g., the following is a collection of four 3-dimensional vectors:
可以将标量视为大小为1x1的矩阵,因此它的转置与原始标量相同.
A scalar can be thought of as a matrix of size 1x1, and therefore its transpose is the same as the original.
通常,n×m矩阵 W
也可以看作是从m维向量 x
到n维向量 y
,因为将该矩阵与m维向量相乘会得到一个新的n维向量.如果您的矩阵" W
是"1xn",则表示从n维向量到标量的转换.
More generally, an n-by-m matrix W
can also be thought of as a transformation from an m-dimensional vector x
to an n-dimensional vector y
, since multiplying that matrix with an m-dimensional vector will yield a new n-dimensional one. If your 'matrix' W
is '1xn', then this denotes a transformation from an n-dimensional vector to a scalar.
因此,从概念上讲,习惯上是从数学表示法的角度介绍问题的,例如 y = Wx
.
Therefore, notationally, it is customary to introduce the problem from the mathematical notation point of view, e.g. y = Wx
.
但是,出于计算的原因,有时将计算作为向量乘以矩阵"而不是矩阵乘以向量"更有意义.由于(Wx)'=== x'W'
,有时我们会解决类似的问题,并将 x'
视为水平向量.另外,如果 W
不是矩阵,而是标量,则 Wx
表示标量乘法,因此在这种情况下 Wx === xW
However, for computational reasons, sometimes it makes more sense to perform the calculation as a "vector times a matrix" rather than "matrix times a vector". Since (Wx)' === x'W'
, sometimes we solve the problem like that, and treat x'
as a horizontal vector. Also, if W
is not a matrix, but a scalar, then Wx
denotes scalar multiplication, and therefore in this case Wx === xW
.
我不知道您所说的练习,但我的假设是他在课程中引入了 theta
作为适当的垂直向量,然后对其进行了转换以进行适当的计算,即从n维向量到标量的转换(这是您的预测).
I don't know the exercises you speak of, but my assumption would be that in the course he introduced theta
as a proper, vertical vector, but then transposed it to perform proper calculations, i.e. a transformation from a vector of n-dimensions to a scalar (which is your prediction).
然后在练习中,大概是您或正在处理标量"theta",因此没有转置它的点,为方便起见, 或都被保留为theta.em> ,现在将theta定义为水平(即转置)矢量,出于某种原因(例如打印方便)开始,然后在执行必要的转换时留在该状态.
Then in the exercises, presumably you were either dealing with a scalar 'theta' so there was no point transposing it, and was left as theta for convenience or, theta was now defined as a horizontal (i.e. transposed) vector to begin with for some reason (e.g. printing convenience), and then was left in that state when performing the necessary transformation.
这篇关于在实际中,为什么theta * X不是theta'* X?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!