Advanced Optimization(高级优化)

Note: [7:35 - ‘100‘ should be 100 instead. The value provided should be an integer and not a character string.]

"Conjugate gradient", "BFGS", and "L-BFGS" are more sophisticated, faster ways to optimize θ that can be used instead of gradient descent. We suggest that you should not write these more sophisticated algorithms yourself (unless you are an expert in numerical computing) but use the libraries instead, as they‘re already tested and highly optimized. Octave provides them.

We first need to provide a function that evaluates the following two functions for a given input value θ:

We can write a single function that returns both of these:

function [jVal, gradient] = costFunction(theta)
  jVal = [...code to compute J(theta)...];
  gradient = [...code to compute derivative of J(theta)...];
end

Then we can use octave‘s "fminunc()" optimization algorithm along with the "optimset()" function that creates an object containing the options we want to send to "fminunc()". (Note: the value for MaxIter should be an integer, not a character string - errata in the video at 7:30)

options = optimset(‘GradObj‘, ‘on‘, ‘MaxIter‘, 100);
initialTheta = zeros(2,1);
   [optTheta, functionVal, exitFlag] = fminunc(@costFunction, initialTheta, options);

 We give to the function "fminunc()" our cost function, our initial vector of theta values, and the "options" object that we created beforehand. 

  

时间: 2024-08-07 08:34:22

Advanced Optimization(高级优化)的相关文章

linux内核高级优化脚本

linux内核高级优化脚本可以用于hadoop生态圈环境的组件安装 linux内核调优具体的每一步的解释请参考 03搭建cdh备注:使用与centos6和centos7两个系统版本执行 [[email protected] scripts]# pwd /opt/scripts [[email protected] scripts]# ll total 12 -rw-r--r-- 1 root root 3837 Apr 22 14:34 adlinuxopt.sh -rw-r--r-- 1 ro

Unity3d iOS基本优化和高级优化

原地址:http://www.cocoachina.com/bbs/read.php?tid=70395&page=1 分享看见的2篇好文.简单翻译了一下并且放出原文http://www.cratesmith.com/archives/1831.做减法大量代码在Update()或FixedUpdate()中做处理,意味着无论代码的执行速度如何,都将在每次帧刷新的时候调用到, 复制代码 public class MyHoming : MonoBehaviour { public void Upda

Convex optimization 凸优化

zh.wikipedia.org/wiki/凸優化 以下问题都是凸优化问题,或可以通过改变变量而转化为凸优化问题:[5] 最小二乘 线性规划 线性约束的二次规划 半正定规划 Convex function Convex minimization is a subfield of optimization that studies the problem of minimizing convex functions over convex sets. The convexity makes opt

IIS下Advanced Logging(高级日志)的安装以及X-Forwarded-For的配置

下载地址:https://www.microsoft.com/en-gb/download/details.aspx?id=7211 1.启动IIS管理器,然后点击左侧的服务器名称,(注意:不要点击网站下的站点或虚拟目录,否则找不到下面的" Enable Advanced Logging"): 2.在主页中,双击IIS下的" Advanced Logging": 3.点击右侧操作窗格中的" Enable Advanced Logging"(启用高

CMU Convex Optimization(凸优化)笔记1--凸集和凸函数

CMU凸优化笔记--凸集和凸函数 结束了一段时间的学习任务,于是打算做个总结.主要内容都是基于CMU的Ryan Tibshirani开设的Convex Optimization课程做的笔记.这里只摘了部分内容做了笔记,很感谢Ryan Tibshirani在官网中所作的课程内容开源.也很感谢韩龙飞在CMU凸优化课程中的中文笔记,我在其基础上做了大量的内容参考.才疏学浅,忘不吝赐教. 1.凸集合 1.1 基本概念 定义:给定一个集合$C \subseteq \mathbb{R}^n $,满足下列条件

机器学习的简单逻辑回归的Advanced Optimization

Learning Course: One variable logistic regression optimization 单变量(只有一个特征)的用于分类的逻辑回归的cost function的最小值求解, here: x=[x1;x2]; y={0,1}; theta=[theta(1);theta(2)] 由于分类中的y值需为0-1之间的数值,因此这里的cost function不同于线性回归的cost function. hθ(x)=g(θTx), where g(x)= 1/(1-e

SQL优化策略高级优化经常使用-1(The Return Of The King)

1 经常使用的优化策略 1.1    语句 1.1.1使用实际的列名 当我们查询SQL语句时.你是否觉得使用实际的列名比使用*更快呢?答案是肯定的. 为了证实这一点,感兴趣的朋友能够自己验证一下.我这里给出一个实例. select * from user; --时间: 0.423ms</span> select id,version,avatar,date_created,description,email,email_show ,enabled,first_name,last_name,la

11 高级优化技术

需要先解决基本性能问题, 如果性能仍无法被接受, 才来考虑以下方法. 物化视图 materialized view, 结果缓存 result cache, 并行处理 parallel prcess, 直接路径插入 direct-path insert, 行预取, 数组接口 物化视图 视图是一个虚拟表, 基于它创建时指定的查询语句返回结果集, 每次访问它都会导致这个查询语句被执行一次, 为了避免每次访问都执行这个查询, 可以将这个查询的结果集存储到一个物化视图中, 也就是说, 物化视图只是对已经存

Unity Optimization UNITY优化关注列表

这里主要罗列Unity引擎进行开发的应用或游戏,可以进行优化的各个关注点.(此文会持续更新) C# GC alloc Update LateUpdate Serialize String ToString() += Getter API Object.name GetComponents Sprite.vectices Debug.Log Closure anonymous function Unity API ParticleSystem Start Stop Pause Clear Simu