IndentationError: expected an indented block如何处理
在做到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如何处理相关推荐
- Python : IndentationError: expected an indented block
如下图 运行包报错: IndentationError: expected an indented block 处理方法是 问题原因 1冒号后面要跟要写一些内容的, 2 其他位置,或多或少空格的位置不 ...
- python 报错 IndentationError: expected an indented block SyntaxError: invalid character in identifie
红色方框那里敲击一个空格就好! 输入要在全英情况下! 另外,还要注意括号的事情.括号别出错误! IndentationError: expected an indented block的报错: Syn ...
- python问题:IndentationError:expected an indented block错误解决
原文地址 http://blog.csdn.net/neilhappy/article/details/7724959 Python语言是一款对缩进非常敏感的语言,给很多初学者带来了困惑,即便是很有 ...
- 成功解决python中出现的IndentationError: expected an indented block的错误
成功解决python中出现的IndentationError: expected an indented block的错误 目录 解决问题 解决思路 解决方法 解决问题 当在python中出现这个错误 ...
- Python报错:IndentationError: expected an indented block
IndentationError: expected an indented block 直译为:缩进错误:需要缩进的块 在Python中,函数间的判定归属由缩进的块来决定而不是一组组括号 出现这个错 ...
- 解决错误:IndentationError:expected an indented block
这样的错IndentationError:expected an indented block说明此处需要缩进,你只要在出现错误的那一行,按空格或Tab(但不能混用)键缩进就行. 有冒号的下一行往往要 ...
- IndentationError:expected an indented block错误解决
IndentationError:expected an indented block错误解决 描述: 有时一个简单的问题会困扰很久,当发现问题后才感觉自己是多蠢,下面记录一个在日常Python编程过 ...
- python出现expected an_Python错误:IndentationError:expected an indented block怎么解决
出现 IndentationError:expected an indented block 错误 一般是因为缩进问题引起的. 实例分析: 错误代码: >>> for key in ...
- python 报错:IndentationError: expected an indented block
def get_formatted_name_0(first_name,last_name,middle_name=''):"""返回整洁的姓名""& ...
最新文章
- C#各种小知识点总结
- 线程的创建开销大吗?线程创建开销包括哪些?线程池
- ASP.NET 之 MVC框架及搭建
- 数据分析案例:亚洲国家人口数据计算
- 产品经理学习---高级产品经理
- 《云云众声》第95期:业界大事接着看 HP成功收购Aruba;IBM战略变动 前景发展被看好...
- matlab 传递函数求截止频率,高分求解RC滤波电路的传递函数和截止频率
- mysql if / case / limit / join / 数据类型 、oracle decode 及其它sql对比
- 计算机主机光驱弹不出来怎么办,win7系统电脑按下光驱按钮托盘就是弹不出来怎么办...
- HQChart使用教程92-如何创建分笔明细表
- linux输入文件后clustalw,ClustalW----多序列比对分析(一)
- 太阳能光伏发电和路灯应用系统的详细计算
- 2023年安徽省中职网络安全跨站脚本攻击
- 网上很牛逼的IT技术网站
- LruCache源码的理解
- 基于matlab振动信号处理,基于PC及MATLAB的振动信号处理的实现
- pip安装pytorch 清华镜像
- 卓有成效的管理者笔记
- ORMLite的集成和使用
- AndroidHttpCapture 网络诊断工具 是一款针对于移动流量劫持而开发的手机抓包软件
热门文章
- 刚刚公布的 Log4J 的史诗级安全漏洞 CVE-2021-44228 你处理了吗?
- RK3588通用布线设计指南
- Eclipse中使用git解决冲突的方法
- Wallis公式以及Stirling公式在程序中的应用
- 教你怎么用59秒就能打动客户,想快速赚钱一定来
- 文件上传 华为云服务器,文件上传云服务器
- tensorflow的写诗代码分析【转】
- 赶紧收藏 | 50个超实用微信小程序,巨好用|||内含免费配音软件
- 微软云架构服务器,Azure 云服务(经典)NetworkConfiguration 架构 | Microsoft Docs
- 第五届传智杯-初赛【A组-题解】