日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

UFLDL 教程学习笔记(一)

發布時間:2024/10/12 编程问答 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 UFLDL 教程学习笔记(一) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

? ? ?ufdl的新教程,從基礎學起。第一節講的是線性回歸。主要目的是熟悉目標函數,計算梯度和優化。

? ? ?按著教程寫完代碼后,總是編譯出錯,一查是mex的原因,實在不想整了。

? ? ?這位博主用的是向量,比較簡潔:http://blog.csdn.net/lingerlanlan/article/details/38377023

? ? ? 這位博主用的是循環,更好理解:http://www.cnblogs.com/william7neral/p/4448566.html

? ? ? 接下來是logistic regression和向量化,沒什么好說的:http://blog.csdn.net/lingerlanlan/article/details/38390085

? ? ??

? ? ? 這節主要是完成liner_regression.m,包括計算目標函數f和梯度g,需要注意的是要分清變量是列向量還是行向量或是矩陣。

? ? ? ?對matlab不太熟,所以我稍微注釋了下

? ? ??

function [f,g] = linear_regression(theta, X,y)%% Arguments:% theta - A vector containing the parameter values to optimize.列向量% X - The examples stored in a matrix.% X(i,j) is the i'th coordinate of the j'th example.% y - The target value for each example. y(j) is the target for% example j.行向量%%size(a,1)求矩陣的行數 size(a,2)求矩陣的列數,相當于length(a)%size(a)同時求矩陣的行和列數% m=size(X,2);m = size(X,2);n=size(X,1);f=0;g=zeros(size(theta));%% TODO: Compute the linear regression objective by looping over the examples in X.% Store the objective function value in 'f'.%% TODO: Compute the gradient of the objective with respect to theta by looping over% the examples in X and adding up the gradient for each example. Store the% computed gradient in 'g'.%%% YOUR CODE HERE %%% h = theta' * X f = (1/2)* (h-y)' * (h-y) g = X * (h - y)' View Code

?

? ? ??

?

? ? ??

轉載于:https://www.cnblogs.com/573177885qq/p/4783465.html

總結

以上是生活随笔為你收集整理的UFLDL 教程学习笔记(一)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。