Python
mmmdotes
softness is power.
展开
-
TensorFlow官方文档中的sub 和mul中的函数已经在API中改名了
照着tensorflow 官方文档学习tensorflow时,出现问题:第一,执行程序#进入一个交互式Tensorflow会话import tensorflow as tfsess = tf.InteractiveSession()x = tf.Variable([1.0,2.0])a = tf.constant([3.0,3.0])#使用初始化器initalizer op的原创 2018-01-26 12:19:17 · 1594 阅读 · 0 评论 -
Review Python Numpy 数组的初始化和基本操作
一.基础:Numpy的主要数据类型是ndarray,即多维数组。它有以下几个属性:ndarray.ndim:数组的维数 ndarray.shape:数组每一维的大小 ndarray.size:数组中全部元素的数量 ndarray.dtype:数组中元素的类型(numpy.int32, numpy.int16, and numpy.float64等) ndarray.itemsize:...原创 2018-11-20 07:26:31 · 622 阅读 · 0 评论 -
计算几个变量之间的相关系数,计算协方差矩阵时:TypeError: cannot perform reduce with flexible type
环境:python 3.6 + win10IDE: pycharm community 2017.3 问题分析:在进行对相关系矩阵进行归一化时,出错,TypeError: cannot perform reduce with flexible type,<<print(a.dtype)<< <U9 **重点是 ndarray(即多维数...原创 2018-11-20 05:27:30 · 1205 阅读 · 0 评论 -
CSV与List的互相转换(python实现)
环境:python3.6IDE: pycharm community 2017.31.读取CSV文件到Listdef read_CSV2List(filePath): try: file=open('C:/a.csv','r',encoding="gbk")# 以utf-8形式编码 context = file.read() # 以str形式读取 list_resul...原创 2018-11-20 01:53:05 · 5171 阅读 · 1 评论 -
Python的list中的选取范围
序列是Python中最基本的数据结构。序列中的每个元素都分配一个数字 - 它的位置,或索引,第一个索引是0,第二个索引是1,依此类推。Python有6个序列的内置类型,但最常见的是列表和元组。序列都可以进行的操作包括索引,切片,加,乘,检查成员。此外,Python已经内置确定序列的长度以及确定最大和最小的元素的方法列表是最常用的Python数据类型,它可以作为一个方括号内的逗号分隔值出现。列表的数...原创 2018-04-13 12:57:50 · 60351 阅读 · 3 评论 -
线程安全机制 python
#!/usr/bin/env python# _*_coding:utf-8 _*_#@Time :2018/4/4 18:50#@Author :niutianzhuang#@FileName: thread_Lock.py#@Software: PyCharm'''多线程安全机制--使用锁 threading.Lock()从程序逻辑角度,python和java的多线程安...原创 2018-04-04 20:19:52 · 1676 阅读 · 2 评论 -
Python3 格式化输出 %s & %d 等
1.打印字符串print("My name is %s" %("Alfred.Xue"))#输出效果:My name is Alfred.Xue2.打印整数print("I am %d years old." %(25))#输出效果:I am 25 years old.3.打印浮点数print ("His height is %f m"%(1.70))#输出效果:His height is 1...原创 2018-03-29 00:37:57 · 8265 阅读 · 0 评论 -
很有必要看,这篇 解决 IndexError: list index out of range
运行逻辑回归代码,遭遇bug:Traceback (most recent call last): File "D:/DTLFolder/paperTest/Paper_logistic regression.py", line 92, in <module> GetResult() File "D:/DTLFolder/paperTest/Paper_logistic...原创 2018-04-03 00:54:37 · 41131 阅读 · 2 评论 -
python 关键字 及代码
1.and:表示逻辑‘与’2.del:用于list列表操作,删除一个或者连续几个元素。3.from:导入相应的模块,用import或者from...import4.not:表示逻辑‘非’5.while:while循环,允许重复执行一块语句,一般无限循环的情况下用它。示例如下:while Ture: if a > b: add()#调用函数求和 else: ...原创 2018-03-31 09:05:36 · 621 阅读 · 0 评论 -
查看python 3.x 关键字 (保留字)(预留字)
查看方法:>>import keyword>>keyword.kwlist原创 2018-03-31 09:02:27 · 6693 阅读 · 0 评论 -
ReadTimeoutError: HTTPSConnectionPool(host='pypi.python.org', port=443): Read timed out.
problem: pip install selenium出现错误:ReadTimeoutError: HTTPSConnectionPool(host='pypi.python.org', port=443): Read timed out.解决办法:换源,如下pip install selenium -i https://pypi.douban.com/simple...原创 2018-03-17 17:15:45 · 3653 阅读 · 0 评论 -
解决 MNIST数据集无法下载脚本input_data.py及pycharm 运行程序下载mnist数据报错[Errno 101] Network is unreachable
# Copyright 2015 The TensorFlow Authors. All Rights Reserved.## Licensed under the Apache License, Version 2.0 (the "License");# you may not use this file except in compliance with the License.# Y原创 2018-01-28 12:05:26 · 7307 阅读 · 0 评论 -
modulenotfounderror: no module 或modulenotfounderror: no module named 'matplotlib._path' 原因详解及解决办法
环境:Ubuntun14.04LTS +Anaconda4.2+tensorflow1.2+pycharm community2017.3.3运行.py文件时,1.出现ImportError: No module named matplotlib.pyplot 2.出现modulenotfounderror:no module namedmatplotlib._path"原创 2018-01-28 12:27:39 · 12166 阅读 · 2 评论 -
解决PyCharm ImportError: No module named tensorflow 详解
运行 TensorFlow MNIST 实验程序时出错报错原因:所用到的python解释器和我们当前PyCharm所用的python解释器不一致说导致.故解决方案,将PyCharm的解释器更改为TensorFlow下的python解释器 即可。具体步骤如下: 第一, 打开终端terminal,找到Python路径 : source activate xxx原创 2018-01-28 02:59:21 · 22729 阅读 · 1 评论 -
python问题:IndentationError:expected an indented block错误解决
原文地址 http://blog.csdn.net/neilhappy/article/details/7724959Python语言是一款对缩进非常敏感的语言,给很多初学者带来了困惑,即便是很有经验的Python程序员,也可能陷入陷阱当中。最常见的情况是tab和空格的混用会导致错误,或者缩进不对,而这是用肉眼无法分别的。在编译时会出现这样的错IndentationError转载 2018-01-26 13:02:01 · 264 阅读 · 0 评论 -
Python数据可视化:幂律分布
1、公式推导 对幂律分布公式: 对公式两边同时取以10为底的对数: 令,且为常数,所以公式变为: 所以对于幂律公式,对X,Y取对数后,在坐标轴上为线性方程。2、可视化 从图形上来说,幂律分布及其拟合效果: 对X轴与Y轴取以10为底的对数。效果上就是X轴上1与10,与10与100的距离是一样的。 对XY取双对数后,坐标轴上点可以很好用直线拟合。所以,判定数据是否符合...转载 2018-12-11 02:35:04 · 4074 阅读 · 0 评论