• ufldl学习笔记与编程作业:Logistic Regression(逻辑回归)


    ufldl学习笔记与编程作业:Logistic Regression(逻辑回归)


    ufldl出了新教程,感觉比之前的好,从基础讲起。系统清晰,又有编程实践。

    在deep learning高质量群里面听一些前辈说。不必深究其它机器学习的算法,能够直接来学dl。

    于是近期就開始搞这个了,教程加上matlab编程,就是完美啊。

    新教程的地址是:http://ufldl.stanford.edu/tutorial/


    本节学习链接:http://ufldl.stanford.edu/tutorial/supervised/LogisticRegression/


    有了线性回归的基础再来学这个。简直是easy啊。

    线性回归一般是拟合,预測的输出一般是连续的。

    而逻辑回归通常来做离散的预測,比方二值的0或者1,也就是分类问题。


    搞懂了目标函数和偏导数后,就能够编程了。


    编程题目是对手写数字0和1做分类。

    logistic_regression.m代码例如以下

    function [f,g] = logistic_regression(theta, X,y)
      %
      % Arguments:
      %   theta - A column 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 label for each example.  y(j) is the j'th example's label.
      %
    
      m=size(X,2);
      
      % initialize objective value and gradient.
      f = 0;
      g = zeros(size(theta));
      
      h = sigmoid(X'*theta);
      f=-y*log2(h)+(1-y)*log2(1-h);
      g=X*(h-y');
      %
      % TODO:  Compute the objective function by looping over the dataset and summing
      %        up the objective values for each example.  Store the result in 'f'.
      %
      % TODO:  Compute the gradient of the objective by looping over the dataset and summing
      %        up the gradients (df/dtheta) for each example. Store the result in 'g'.
      %
    %%% YOUR CODE HERE %%%
    

    结果例如以下:


    教程里说准确率应该是100%,我这里居然是99.7%和99.9%。

    难道我做错了。。

    假设由谁做到100%,记得告诉我啊。


    本文作者:linger

    本文链接:http://blog.csdn.net/lingerlanlan/article/details/38390085




  • 相关阅读:
    [netty4][netty-buffer]netty之池化buffer
    [netty4][netty-transport]netty之nio传输层
    JMX基本概念
    《JVM G1源码分析和调优》读书笔记
    clients-producer-网络处理与请求响应对接部分
    clients-producer-组包发送消息
    kafka-clients 1.0 高阶API消费消息(未完)
    MetadataCache更新
    副本同步
    将.py文件装成这执行文件.exe
  • 原文地址:https://www.cnblogs.com/wzzkaifa/p/6903717.html
Copyright © 2020-2023  润新知