在做到cs231n的assignment1的第一个KNN作业时,跑如下代码反的时候:

    def compute_distances_one_loop(self, X):"""Compute the distance between each test point in X and each training pointin self.X_train using a single loop over the test data.Input / Output: Same as compute_distances_two_loops"""num_test = X.shape[0]num_train = self.X_train.shape[0]dists = np.zeros((num_test, num_train))for i in xrange(num_test):######################################################################## TODO:                                                               ## Compute the l2 distance between the ith test point and all training ## points, and store the result in dists[i, :].                        ######################################################################### pass########################################################################                         END OF YOUR CODE                            ########################################################################return dists

一直提示错误:

Traceback (most recent call last):File "/opt/anaconda3/envs/tensorflow/lib/python3.7/site-packages/IPython/core/interactiveshell.py", line 3417, in run_codeexec(code_obj, self.user_global_ns, self.user_ns)File "<ipython-input-110-833c0369b4cf>", line 1, in <module>from cs231n.classifiers import KNearestNeighborFile "/Users/shili/Downloads/assignment1/cs231n/classifiers/__init__.py", line 1, in <module>from cs231n.classifiers.k_nearest_neighbor import *File "/Users/shili/Downloads/assignment1/cs231n/classifiers/k_nearest_neighbor.py", line 119return dists^
IndentationError: expected an indented block

最后发现,在第一段for循环里面,我把pass给注释掉了。

但是不能注释pass!

即使这个循环留空,也不能什么都不写,也要写一个pass。否则就会报以上的错误!

IndentationError: expected an indented block如何处理相关推荐

  1. Python : IndentationError: expected an indented block

    如下图 运行包报错: IndentationError: expected an indented block 处理方法是 问题原因 1冒号后面要跟要写一些内容的, 2 其他位置,或多或少空格的位置不 ...

  2. python 报错 IndentationError: expected an indented block SyntaxError: invalid character in identifie

    红色方框那里敲击一个空格就好! 输入要在全英情况下! 另外,还要注意括号的事情.括号别出错误! IndentationError: expected an indented block的报错: Syn ...

  3. python问题:IndentationError:expected an indented block错误解决

    原文地址  http://blog.csdn.net/neilhappy/article/details/7724959 Python语言是一款对缩进非常敏感的语言,给很多初学者带来了困惑,即便是很有 ...

  4. 成功解决python中出现的IndentationError: expected an indented block的错误

    成功解决python中出现的IndentationError: expected an indented block的错误 目录 解决问题 解决思路 解决方法 解决问题 当在python中出现这个错误 ...

  5. Python报错:IndentationError: expected an indented block

    IndentationError: expected an indented block 直译为:缩进错误:需要缩进的块 在Python中,函数间的判定归属由缩进的块来决定而不是一组组括号 出现这个错 ...

  6. 解决错误:IndentationError:expected an indented block

    这样的错IndentationError:expected an indented block说明此处需要缩进,你只要在出现错误的那一行,按空格或Tab(但不能混用)键缩进就行. 有冒号的下一行往往要 ...

  7. IndentationError:expected an indented block错误解决

    IndentationError:expected an indented block错误解决 描述: 有时一个简单的问题会困扰很久,当发现问题后才感觉自己是多蠢,下面记录一个在日常Python编程过 ...

  8. python出现expected an_Python错误:IndentationError:expected an indented block怎么解决

    出现 IndentationError:expected an indented block 错误 一般是因为缩进问题引起的. 实例分析: 错误代码: >>> for key in ...

  9. python 报错:IndentationError: expected an indented block

    def get_formatted_name_0(first_name,last_name,middle_name=''):"""返回整洁的姓名""& ...

最新文章

  1. C#各种小知识点总结
  2. 线程的创建开销大吗?线程创建开销包括哪些?线程池
  3. ASP.NET 之 MVC框架及搭建
  4. 数据分析案例:亚洲国家人口数据计算
  5. 产品经理学习---高级产品经理
  6. 《云云众声》第95期:业界大事接着看 HP成功收购Aruba;IBM战略变动 前景发展被看好...
  7. matlab 传递函数求截止频率,高分求解RC滤波电路的传递函数和截止频率
  8. mysql if / case / limit / join / 数据类型 、oracle decode 及其它sql对比
  9. 计算机主机光驱弹不出来怎么办,win7系统电脑按下光驱按钮托盘就是弹不出来怎么办...
  10. HQChart使用教程92-如何创建分笔明细表
  11. linux输入文件后clustalw,ClustalW----多序列比对分析(一)
  12. 太阳能光伏发电和路灯应用系统的详细计算
  13. 2023年安徽省中职网络安全跨站脚本攻击
  14. 网上很牛逼的IT技术网站
  15. LruCache源码的理解
  16. 基于matlab振动信号处理,基于PC及MATLAB的振动信号处理的实现
  17. pip安装pytorch 清华镜像
  18. 卓有成效的管理者笔记
  19. ORMLite的集成和使用
  20. AndroidHttpCapture 网络诊断工具 是一款针对于移动流量劫持而开发的手机抓包软件

热门文章

  1. 刚刚公布的 Log4J 的史诗级安全漏洞 CVE-2021-44228 你处理了吗?
  2. RK3588通用布线设计指南
  3. Eclipse中使用git解决冲突的方法
  4. Wallis公式以及Stirling公式在程序中的应用
  5. 教你怎么用59秒就能打动客户,想快速赚钱一定来
  6. 文件上传 华为云服务器,文件上传云服务器
  7. tensorflow的写诗代码分析【转】
  8. 赶紧收藏 | 50个超实用微信小程序,巨好用|||内含免费配音软件
  9. 微软云架构服务器,Azure 云服务(经典)NetworkConfiguration 架构 | Microsoft Docs
  10. 第五届传智杯-初赛【A组-题解】