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;

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);

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:10for j = 1:10v(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 = A .* x;

v = sum (A * x);

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:7z = 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';

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:7for j = 1:7A(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;

Machine Learning week 2 quiz: Octave Tutorial相关推荐

  1. Machine Learning week 9 quiz: programming assignment-Anomaly Detection and Recommender Systems

    一.ex8.m %% Machine Learning Online Class % Exercise 8 | Anomaly Detection and Collaborative Filterin ...

  2. Machine Learning week 11 quiz: Application: Photo OCR

    Application: Photo OCR 5 试题 1. Suppose you are running a sliding window detector to find text in ima ...

  3. Machine Learning week 10 quiz: Large Scale Machine Learning

    Large Scale Machine Learning 5 试题 1. Suppose you are training a logistic regression classifier using ...

  4. Machine Learning week 8 quiz: programming assignment-K-Means Clustering and PCA

    一.ex7.m %% Machine Learning Online Class % Exercise 7 | Principle Component Analysis and K-Means Clu ...

  5. Machine Learning week 7 quiz: programming assignment-Support Vector Machines

    一.ex6.m %% Machine Learning Online Class % Exercise 6 | Support Vector Machines % % Instructions % - ...

  6. Machine Learning week 6 quiz: Machine Learning System Design

    Machine Learning System Design 5 试题 1. You are working on a spam classification system using regular ...

  7. Machine Learning week 6 quiz: programming assignment-Regularized Linear Regression and Bias/Variance

    一.ex5.m %% Machine Learning Online Class % Exercise 5 | Regularized Linear Regression and Bias-Varia ...

  8. Machine Learning week 5 quiz: programming assignment-Multi-Neural Network Learning

    一.ex4.m %% Machine Learning Online Class - Exercise 4 Neural Network Learning% Instructions % ------ ...

  9. Machine Learning week 6 quiz: Advice for Applying Machine Learning

    Advice for Applying Machine Learning 5 试题 1. You train a learning algorithm, and find that it has un ...

最新文章

  1. keras入门(三)搭建CNN模型破解网站验证码
  2. Oracle buffer状态深入剖析
  3. httpclient帮助类
  4. eclipse远程开发
  5. WEB数据透视表Pivot Table
  6. 计算机安全基础:认证技术知识笔记
  7. 前端学习(768):构造对象与对象区别
  8. HTTP状态保持(cookie、session)
  9. Qt for Android 部署流程分析
  10. Python2读取Excel文件时候文件名称是中文的时候处理
  11. RS232 DB9引脚定义
  12. Oracle 多行显示在一行详解(listagg)
  13. 如何在matplotlib中使用新罗马字体
  14. 运动员(射击)的成绩可以用脑电技术预测吗?
  15. 写给编程初学者的一篇文章,该如何学习编程?我的编程学习之路
  16. 【产业互联网】源码资本眼中的产业互联网:连接赋能构建生态
  17. 用Linux / C实现基于自动扩/减容线程池+epoll反应堆检测沉寂用户模型的服务器框架(含源码)
  18. org.json.JSONException: Value [{“id“:10,“userId“:6,“adminId“:5,“content“:“7777“,“state“:-1,“image1“:
  19. 运维面试题(每日一题)
  20. 2022最新魔方财务管理系统织音①号模板免费下载,智简魔方免费主题模板下载

热门文章

  1. 从0到1建立一张评分卡之变量分箱
  2. 数据结构排序学习总结
  3. 什么是死锁?为什么会死锁?如何解决死锁问题?如何调试死锁问题?
  4. IDEA 启动 Tomcat 乱码 解决办法
  5. Spring-AOP @AspectJ进阶之绑定连接点方法的返回值
  6. Java-CGLib动态代理
  7. ListView使用技巧-更新中
  8. linux定时导出数据库,linux 下定时导出备份oracle数据库
  9. docker新建Linux虚拟机,RHEL/CentOS 7下创建你的第一个Docker容器
  10. python3安装mysql模块_Python3.6 下 安装MySql