https://www.coursera.org/learn/machine-learning/exam/dbM1J/octave-matlab-tutorial

Octave Tutorial

5 试题

1.

Suppose I first execute the following Octave commands:

A = [1 2; 3 4; 5 6];

B = [1 2 3; 4 5 6];

Which of the following are then valid Octave commands? Check all that apply and assume all options are written in an Octave command. (Hint: A' denotes the transpose of A.)

C = A * B;

C = B' + A;

C = A' * B;

C = B + A;

答案: ab (C = A * B 和 C = B' + A;)

2.

Question text

Let A=⎡⎣⎢⎢16594211714310615138121⎤⎦⎥⎥.

Which of the following indexing expressions gives B=⎡⎣⎢⎢16594211714⎤⎦⎥⎥? Check all that apply.

B = A(:, 1:2);

B = A(1:4, 1:2);

B = A(0:2, 0:4)

B = A(1:2, 1:4);

答案 :ab (B = A(:, 1:2);和 B = A(1:4, 1:2);)

3.

Let A be a 10x10 matrix and x be a 10-element vector. Your friend wants to compute the product Ax and writes the following code:

v = zeros(10, 1);

for i = 1:10

for j = 1:10

v(i) = v(i) + A(i, j) * x(j);

end

end

How would you vectorize this code to run without any FOR loops? Check all that apply.

v = A * x;

v = Ax;

v =x'* A;

v = sum (A * x);

答案: a. v = A * x;

v = Ax :Undefined function or variable 'Ax'.

4.

Say you have two column vectors v and w, each with 7 elements (i.e., they have dimensions 7x1). Consider the following code:

z = 0;

for i = 1:7

z = z + v(i) * w(i)

end

Which of the following vectorizations correctly compute z? Check all that apply.

z = sum (v .* w);

z = w' * v;

z = v * w';

z = w * v';

答案: ab (z = sum (v .* w);和 z = w' * v; )

column vectors 列向量

5.

In Octave, many functions work on single numbers, vectors, and matrices. For example, the sin function when applied to a matrix will return a new matrix with the sin of each element. But you have to be careful, as certain functions have different behavior. Suppose you have an 7x7 matrix X. You want to compute the log of every element, the square of every element, add 1 to every element, and divide every element by 4. You will store the results in four matrices, A,B,C,D. One way to do so is the following code:

for i = 1:7

for j = 1:7

A(i, j) = log(X(i, j));

B(i, j) = X(i, j) ^ 2;

C(i, j) = X(i, j) + 1;

D(i, j) = X(i, j) / 4;

end

end

Which of the following correctly compute A,B,C, or D? Check all that apply.

C = X + 1;

D = X / 4;

B = X .^ 2;

B = X ^ 2;

答案: abc

B = X .^ 2 而不是 X ^ 2

Coursera machine learning 第二周 quiz 答案 Octave/Matlab Tutorial的更多相关文章

  1. Coursera machine learning 第二周 quiz 答案 Linear Regression with Multiple Variables

    https://www.coursera.org/learn/machine-learning/exam/7pytE/linear-regression-with-multiple-variables ...

  2. Coursera machine learning 第二周 编程作业 Linear Regression

    必做: [*] warmUpExercise.m - Simple example function in Octave/MATLAB[*] plotData.m - Function to disp ...

  3. Machine Learning – 第2周(Linear Regression with Multiple Variables、Octave/Matlab Tutorial)

    Machine Learning – Coursera Octave for Microsoft Windows GNU Octave官网 GNU Octave帮助文档 (有900页的pdf版本) O ...

  4. 吴恩达Machine Learning 第一周课堂笔记

    1.Introduction 1.1 Example        - Database mining        Large datasets from growth of automation/ ...

  5. 吴恩达《深度学习》-第一门课 (Neural Networks and Deep Learning)-第二周:(Basics of Neural Network programming)-课程笔记

    第二周:神经网络的编程基础 (Basics of Neural Network programming) 2.1.二分类(Binary Classification) 二分类问题的目标就是习得一个分类 ...

  6. Coursera Machine Learning 作业答案脚本 分享在github上

    Github地址:https://github.com/edward0130/Coursera-ML

  7. Coursera, Machine Learning, notes

      Basic theory (i) Supervised learning (parametric/non-parametric algorithms, support vector machine ...

  8. Coursera Machine Learning : Regression 评估性能

    评估性能 评估损失 1.Training Error 首先要通过数据来训练模型,选取数据中的一部分作为训练数据. 损失函数可以使用绝对值误差或者平方误差等方法来计算,这里使用平方误差的方法,即: (y ...

  9. Coursera Machine Learning : Regression 多元回归

    多元回归 回顾一下简单线性回归:一个特征,两个相关系数 实际的应用要比这种情况复杂的多,比如 1.房价和房屋面积并不只是简单的线性关系. 2.影响房价的因素有很多,不仅仅是房屋面积,还包括很多其他因素 ...

随机推荐

  1. JavaScript的filter用法

    Js的有些操作会改变原来的对象:有些操作则不会改变原来对象. 数组的filter方法就不会改变原来数组 利用filter,可以巧妙地去除Array的重复元素: 'use strict'; var r, ...

  2. 访问php程序无法解析,排查步骤

    1.安装lamp后,php程序没有被解析 (1) apachectl -M 看是否加载了libphp5.so ,apachectl -M 这个命令查看动态libphp5.so的是否由apache加载 ...

  3. 自助采样法 bootstrap 与 0.632

  4. EasyUI Tree 动态传递参数

    1.问题背景 一般出现在加载的时候,传递参数给后台,进行数据筛选,然后在加载tree渲染数据.所谓动态参数,可以是你的上一级节点node,或者是根节点node. 2.涉及方法 onBeforeLoad ...

  5. shell中declare命令

    declare命令有如下选项: -a 声明一个数组 -i 声明一个整型 -f 打印所有函数定义 -F 仅打印函数名字 -r 声明一个readonly变量,该变量的值无法改变,并且不能为unset -x ...

  6. Tomcat 启动或者发布项目时提示Publishing failed:Resource /xxxx does not exist

    解决方法: 刷新一下项目,有可能是磁盘文件和Eclipse项目中文件不一致造成的. 重新启动eclipse 删除tomcat server 重新发布下即可

  7. 倍福TwinCAT(贝福Beckhoff)基础教程 松下伺服驱动器报错 40怎么办

    出现这种错误的时候,我把一套测试完好的电机和驱动器,直接把跟电机连接的线拔掉换另一个电机,驱动器所有参数不变,这样由于是绝对值编码器的,所以驱动器已经记住了上一个电机的圈数,换了新的电机之后圈数不对了 ...

  8. Laravel之认证服务

    一.用户认证 配置文件在config/auth.php下 1.添加认证路由 // 认证路由... Route::get('auth/login', 'Auth\AuthController@getLo ...

  9. 使用RTTI为继承体系编写”==”运算符

    转载请注明出处:http://www.cnblogs.com/inevermore/p/4012079.html   RTTI,指的是运行时类型识别技术.   先看一个貌似无关的问题:   为继承体系 ...

  10. 推荐系统学习(2)——基于TF-IDF的改进

    使用用户打标签次数*物品打标签次数做乘积的算法尽管简单.可是会造成热门物品推荐的情况.物品标签的权重是物品打过该标签的次数,用户标签的权重是用户使用过该标签的次数.从而导致个性化的推荐减少,而造成热门 ...