简体   繁体   English

用输入法写出sigmoid函数(X * theta)

[英]Writing sigmoid function with input as (X * theta)

In Machine learning course, I am unable to visualize below input. 在机器学习课程中,我无法在下面输入可视化。

we have below equation in Logistic Regression : 我们在Logistic回归中有以下等式:

在此输入图像描述

We can write it in octave as below in sigmoid.m : 我们可以在sigmoid.m以下八度语写它:

g = (1 ./ ( 1 + e.^(-z)));

Now, to calculate costFUnction.m , we are getting probability as: 现在,为了计算costFUnction.m ,我们得到概率为:

h = sigmoid(X*theta);

From, the above picture, shouldn't it be: 从上面的图片来看,不应该是:

h = sigmoid(theta'*X);

What am I missing here. 我在这里想念的是什么 I am newbie to ML so forgive me if I am missing something here. 我是ML的新手,请原谅我,如果我在这里遗漏了什么。

The most important thing is to understand what every vector means. 最重要的是要了解每个向量的含义。 In most courses they talk about 在他们谈论的大多数课程中

    h = theta'* x

But here they use colum vectors so h is a scalar for one training example. 但是在这里他们使用colum向量,所以h是一个训练例子的标量。 The vectorized notation tells you 矢量化符号告诉你

    h = X * theta

Where X is a matrix all your training examples, where each example is a row and the features are colums. 其中X是矩阵的所有训练示例,其中每个示例都是一行,而要素是列。 So mxn with m number of training examples and n number of features. 所以mxn有m个训练样例和n个特征。 You want h to give an output for each training example so you want amx 1 matrix. 您希望h为每个训练示例提供输出,因此您需要amx 1矩阵。 You know that theta will be anx 1 matrix as it is a theta for each feature and you have 1 model. 你知道theta将是一个焦点1矩阵,因为它是每个特征的θ,你有1个模型。 If you do the second formula i wrote down at the top you will get as hamx 1 matrix which is prefered. 如果你做了第二个公式,我在顶部写下你将得到哈希1矩阵,这是首选。

If you'll refer to the material shared here , you can see that 如果您将参考此处分享的材料 ,您可以看到

在此输入图像描述

and what we want from h(x) is: 我们想从h(x)是:

在此输入图像描述

在此输入图像描述

to visualize it: 想象它:

X =  [ 1 x1 ; 1 x2 ; 1 x3;]
theta = [ t0 t1;]
X * theta
% will give  [ t0+(x1*t1) ; t0+(x2*t1) ; t0+(x3*t1) ; ] 

where each row of above matrices represent separate hypothesis. 其中上述矩阵的每一行代表单独的假设。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM