CS 231 Spring 2024 ASSIGNMENT 4Python

Java Python CS 231, Spring 2024

ASSIGNMENT 4

Due date:July 24,202416:00(Waterloo time)

Coverage: Through Module 10

This  assignment  consists  of  a   written  component  and  a  programming  component.Please read the instructions on the reference page for assignments carefully to ensure that you  submit each  component  correctly.

Please check the pinned FAQ in the discussion forum for corrections and clarifications.

Note:In  assignment  questions  that  specify  the  use  df  aparticular paradigm,you  are  expected to  come up with  a new  algorithm using that paradigm.It)is not  sufficient to  implement  a  class example  as  a  helper  function  and  declare  that the paradigm has been used.

Written component

For full marks,you are expegted to provide a brief justifcation  of any  answer you provide.

W1.[6 marks]In Assignment 2,we  considered  a  greedy  algorithm  for  finding  as  maximum  size cluster  in  a  graph.Here  we  will  consider  the  algorithm  as  an  approximation  algorithm.

(a)[1  mark]What  is  the  approximation  ratio  when  the  instance  is  a  complete  graph  on at  least  two  vertices?Briefly  justify  your  answer.

(b)[1 mark]What  is  the  approximation  ratio  when  the  instance  is  a  tree  on  at  least  two vertices?Briefly  justify  your  answer.

(c)[4  marks]Give  a  family  of  graphs   for   which   the  approximation  ratio  cannot  be bounded   above   by   a   constant.That   is,provide   a   function   f(n),where   f(n)is   not a  constant  function,such  that  the  ratio  between  the  approximate  and  the  optimal solution  is  at  least  f(n).You  do  not  need  to  provide  a  graph  for  each  value  of  n, but you should show how to form an infinite family ofgraphs of increasing size.As in W2  of Assignment  2,the  statement  should  hold  for  any  ordering  of  the  vertices,no matter how ties are broken.

W2.[6 marks]In this question,we will consider two possible backtracking algorithms for CLUS- TER PARAMETERIZED BY CLUSTER SIZE,defined as follows:

Input: A graph G and a positive integer k

Output: Yes  or  no,answering“Is  there  a  cluster  in  G  of  size k? Parameter: k

For each of the algorithms described below,answer the following two questions:

●  Is  the  worst-case  running  time  of  the  algorithm  in  f(k)·n⁰(1)?

●  Is  the  proposed  algorithm  guaranteed  to  produce  the  correct  answer?

(a)[3  marks]Form  a  search  tree  in  which  the  root  corresponds  to  the  empty  set.At each node,form a child for each node not already in the set that is a neighbour of all nodes  in  the  set  (vacuously  true  for  the  empty  set).Stop  after  k+1  levels,producing true if a node is formed and false otherwise.

(b)[3  marks]Order  the  vertices.Form.  a  search  tree  in  which  the  root  corresponds  to  the empty  set.At  each  node,for  the  next  vertex  in  order,create  one  set  that  contains the vertex (if CS 231, Spring 2024 ASSIGNMENT 4Python  it and the current contents of the set form a cluster)and one that does not  contain  the  vertex.Stop  after  k+1  levels,producng  true  if  a   node  is  formed and false otherwise.

W3.[9 marks]In this question,you will use hilkclimblng for the problem of REPRESENTATIVE SETS,as defined in Assignment 2.

(a)[3  marks]Describe  a  hill-climbing  apprdach,including  the  initial  solution  and  how  it is  updated  at  each  step.For  full  marks,be  sure  to  explain  why  your  approach  can be classified as hill-clambing

(b)[3  marks]Provide  an  input  on  which  your  approach  is  guaranteed  to  produce  the optimal solution.Yout input mast contain at least 4 sets,and each set must contain at least 2 values.Briefly justify your answer by explaining how your approach performs on the provided  input  ahd why  the  solution  is  optimal.

(c)[3 marks]Provide  an  input  on  which  your  approach  is not guaranteed  to provide the optimal  solution.Your  input  must  contain  at  least  4  sets,and  each  set  must  contain at  least  2  values.Briefly  justify  your  answer  by  discussing  both  the  output  of  the approach  and  the  optimal  solution.

W4.[3 marks]An algorithm for REPRESENTATIVE SETs forms a solution B as follows:consid- ering  each  set  in A  one by  one,randomly  choose whether  or not to put the  set  in  B.The probability  of adding  a  particular  set  is  1/2,so  the  probability  of  omitting  it  is  also  1/2. For  the  purpose  of  this  question,we'll  define“high  probability”(of  producing  the  correct  answer)to  be  any  probability  that  is  greater  than  3/4.

(a)[1  mark]Does  the  algorithm  fit  the  definition  of  a  Las  Vegas  algorithm?

(b)[1  mark]Does  the  algorithm  fit  the  definition  of  a  Monte  Carlo  algorithm?

(c)[1 mark]Is there  ever  a reason  that  one might  choose to use  a  randomized  algorithm for  a  problem  in  P?Briefly justify  your  answer.

Programming component

Please read the information on assignments and Python carefully to ensure that you are using  the  correct  version  of  Python  and  the  correct  style.For  full  marks,you  are  required not only to have a correct solution,but also to adhere to the requirements of the assignment question and the style guide,including aspects of the design recipe.

Although submitting tests is not required,it is highly recommended that you test your code. For each assignment question,create a testing file that imports your submission and tests the code.Do not submit your testing file.

For any of the programming questions in this assignment,you may import any of the  fol- lowing  files:check.py,graphs.py,and  equiv.py,as  well  as  built-in  modules  such  as  math  and copy.

Be sure to read the instructions on the Python requirements page to ensure that you have imported the files as required.

P1.[14 marks]Write a function cluster_backtrack that consumes a graph and produces a list of IDs of vertices that forms a cluster of maximum size.Your function should use backtracking.

Submit your work in a fle with the name clusterbacktrock.py         

  • 14
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: CS231n 第三次作业的内容包括使用深度学习来完成图像分类任务。具体来说,包括使用卷积神经网络 (CNN) 来训练图像分类器,并使用预训练网络 (pre-trained network) 来进行微调 (fine-tuning)。还可能包括使用数据增强 (data augmentation) 来提高模型的泛化能力,以及使用可视化工具来理解 CNN 的内部工作原理。 ### 回答2: CS231n作业3是斯坦福计算机视觉课程的第三个作业,该作业涵盖深度学习模型的生成和推理,以及如何创建生成性对抗网络(GAN)。 此次作业主要涉及三个任务: 1. Image Captioning 图片说明任务,也是本次作业的第一个任务。仔细研读与Image Captioning任务相关的代码,并以此为基础,使用RNN中的LSTM层来生成图像的描述。这个一项技术非常实用,可以让图片在搜索引擎中体现出来,提高用户使用体验。学生需要研究encoder和decoder的实现,了解他们生成文本的方法。最终,利用逆向传播算法(反向传播算法)训练神经网络,学习生成图像标题。 2. Generative Adversarial Networks 生成对抗网络是GAN。G和D两个模型构成了GAN模型,是一种强大的生成模型。在这个任务中,学生需要学习如何训练GAN模型,以生成看起来像真实图像的图像样本。这是一个非常复杂的问题,需要合理运用损失函数,较好的优化GAN的训练中表现良好。 3. Neural Style Transfer 神经风格迁移属于图像处理范畴,学生需要实现单张图像的神经风格迁移。方法是,利用一些随机初始化参数,以迭代方式计算输入图像的内容特征和样式特征。最终,需要使用反向传播算法来搜索图像处理的最佳策略。 总之,本次作业难度系数较大,但同时学生在操作过程中也能够学到很多使用深度学习技术解决实际问题的方法,提高对于深度学习的理解、掌握和技能。同时,希望学生能够在本次作业中体验到收获成功带来的成就感。 ### 回答3: CS231n Assignment 3是斯坦福大学计算机视觉课程中的一项作业,主要涉及深度强化学习。它由三个部分组成:Q-learning,Policy Gradients和Actor-Critic。 在Q-learning部分,学生需编写代码来实现Q-learning算法,在智能体与环境之间折衷时间、奖励和学习。Q-learning是一种基于回合的控制算法,它基于时间步长内的奖励和马尔科夫决策过程。在此过程中,学生需要选择一个平衡折衷,以便在训练智能体时最大限度地提高其性能。 在Policy Gradients部分,学生需实现策略梯度算法,该算法通过学习如何最大化预期回报来优化策略。在此步骤中,学生还将学习如何使用梯度上升法确定策略参数。策略梯度算法基于沿向目标策略方向更新参数的概念。 在Actor-Critic部分,学生需实现Actor-Critic算法,这是一种Q-learning和策略梯度算法的组合。该算法包括两个部分:演员即策略,用于决定智能体应采取的行动,评论家即Q值估算器,根据当前状态值和行动值返回平均价值。这两个部分相互作用,以帮助智能体学习最佳策略。 总的来说,CS231n Assignment 3是一项具有挑战性的作业,涉及深度强化学习的各个方面,需要学生掌握许多概念和算法,并将它们应用于代码实现中。完成此项作业需要时间和耐心,但完成后,学生将获得对深度强化学习的深刻理解,这对于今后从事计算机视觉工作将大有裨益。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值