
python
wxysunshy
研究开发
展开
-
列表查询:子列表在父列表的索引
查找列表a在列表b的索引例如:a = [2,3,4,5,6,9]b = [2,3,9]则返回index_list = [0,1,5]方法:index_dict = dict((value, idx) for idx,value in enumerate(a))[index_dict[x] for x in b]out : [0, 1, 5]原创 2020-07-14 11:08:27 · 555 阅读 · 2 评论 -
安装Jupyter NbExtensions Configurator插件
Jupyter NbExtensions Configurator 是Jupyter Notebook的一个扩展工具,只需勾选相应插件就能自动载入。可以让你在Jupyter Notebook上的工作效率进一步的提高。pip install jupyter_nbextensions_configurator jupyter_contrib_nbextensionsjupyter contr...原创 2020-05-07 17:38:31 · 5531 阅读 · 0 评论 -
BUG:Failed to import pydot. You must install pydot and graphviz for `pydotprint`
博主Ubuntu系统,利用plot_model输出图网络时报错:Failed to import pydot. You must install pydot and graphviz for `pydotprint`解决方法:#安装包conda install pydotplusconda install graphviz import pydotplusfrom k...原创 2020-04-28 11:03:20 · 252 阅读 · 0 评论 -
技巧:Python调用上级目录
Python调用上级目录程序方法之一:import syssys.path.append("..")原创 2020-04-02 15:55:23 · 1289 阅读 · 0 评论 -
TimeDistributed理解
keras.layers.TimeDistributed(layer)这个封装器将一个层应用于输入的每个时间片。输入至少为 3D,且第一个维度应该是时间所表示的维度。考虑 32 个样本的一个 batch, 其中每个样本是 10 个 16 维向量的序列。 那么这个 batch 的输入尺寸为(32, 10, 16), 而input_shape不包含样本数量的维度,为(10...原创 2019-12-18 19:53:17 · 1101 阅读 · 0 评论 -
解决:pip is configured with locations that require TLS/SSL
bug:Could not fetch URL https://pypi.python.org/simple/: ...orpip is configured with locations that require TLS/SSL打开终端,输入mkdir ~/.pip cd ~/.pip创建pip.conf文件:touch pip.conf复制粘贴以下配...原创 2019-03-19 22:21:50 · 5872 阅读 · 2 评论 -
解决no module named ‘_ctypes’
安装Python 3.8.0 alpha 2,在make install 时报错:module not found error:no module named ‘_ctypes’ make *** install error 1解决办法:sudo apt-get install libffi-dev继续make install 即可...原创 2019-03-19 17:44:55 · 20507 阅读 · 1 评论 -
bug : No module named 'six
Traceback (most recent call last): File "D:\Anaconda\Scripts\jupyter-notebook-script.py", line 6, in <module> from notebook.notebookapp import main File "D:\Anaconda\lib\site-packages\no...原创 2018-11-19 20:13:23 · 474 阅读 · 0 评论 -
Python学习笔记
问题1:1输出为001, 11输出为011,以三位数的形式输出foriinrange(10):print(str(i).rjust(3,'0'))问题2:文件按名称排序时可以加参数当待排序列表的元素由多字段构成时,我们可以通过sorted(iterable,key,reverse)的参数key来制定我们根据那个字段对列表元素进行排序。 key=lambda ...原创 2018-11-08 17:13:20 · 181 阅读 · 0 评论 -
Python文件操作
第一步 排除文件打开方式错误:r只读,r+读写,不创建w新建只写,w+新建读写,二者都会将文件内容清零(以w方式打开,不能读出。w+可读写)w+与r+区别:r+:可读可写,若文件不存在,报错;w+: 可读可写,若文件不存在,创建r+与a+区别: fd = open("1.txt",'w+') fd.write('123') fd = open("1...转载 2018-10-10 12:33:24 · 142 阅读 · 0 评论 -
sklearn 机器学习笔记
传统的机器学习任务从开始到建模的一般流程是:获取数据 -> 数据预处理 -> 训练建模 -> 模型评估 -> 预测,分类。本文我们将依据传统机器学习的流程,看看在每一步流程中都有哪些常用的函数以及它们的用法是怎么样的。希望你看完这篇文章可以最为快速的开始你的学习任务。1. 获取数据1.1 导入sklearn数据集 sklearn中包含了大量的优质的数据集,在你...原创 2018-09-12 20:35:15 · 194 阅读 · 0 评论