知识点
---Lavender---
在读研究生
展开
-
tf.transpose
tensorflow 里面的 tensor是先从高维向低维算起的 比如:’x’ is [[[1 2 3] [4 5 6]] [[7 8 9] [10 11 12]]] x的维数就是[2,2,3] 而perm的意思就是将tensor对应的不同的维数之间变换 比如perm = [2,1,0],则原tensor = [3, 2,2],全部倒过来 perm = [0,2,1原创 2017-07-31 12:47:41 · 419 阅读 · 0 评论 -
np.vstack
import numpy as npa = [1,2,3]b = [4,5,6]c = np.vstack((a,b))print(c)#[[1,2,3] [4,5,6]]除了在列的方向上叠加,还具有把列表转化成矩阵的功能原创 2017-11-13 15:33:08 · 2487 阅读 · 0 评论 -
sqlites3基本操作
import sqlite3conn = sqlite3.connect("D://python_communication//workspace//TensorFlow//data//test.db")# 使用游标查询数据库cur = conn.cursor()# 建表cur.execute("create table catalog (id integer primary key,p原创 2017-10-16 15:32:56 · 538 阅读 · 0 评论 -
python 中参数*args, **kwargs
python 中参数*args, **kwargsdef foo(*args, **kwargs):print 'args = ', argsprint 'kwargs = ', kwargsprint '---------------------------------------'if __name__ == '__main__':foo(1,2,3,4)转载 2017-10-09 12:29:04 · 1036 阅读 · 0 评论 -
pickle读写
import pickleword = "I love China"with open('test.txt','wb') as f:pickle.dump(word, f)with open('test.txt','rb') as f:temp = pickle.load(f)print(temp)原创 2017-09-21 11:22:26 · 458 阅读 · 0 评论 -
Python中的zip
a = (('e',12),('r',13),('d',10))b,c = zip(*a)print(b)print(c)结果:('e', 'r', 'd')(12, 13, 10)原创 2017-08-25 10:43:46 · 291 阅读 · 0 评论 -
np.argmax()
import numpy as npa = np.array([[1, 5, 5, 2],[9, 6, 2, 10],[3, 7, 9, 1]])print(np.argmax(a, axis=1))#输出(1,3,2)axis=1时函数的作用为每一列进行比较,输出每行中数值最大的索引原创 2017-08-13 19:54:01 · 1571 阅读 · 0 评论 -
np.searchsorted
import numpy as npa = np.random.rand(1)*12print(a)b = [1,2,4]c = np.searchsorted([1,2,4],a)print(c)#二分法查找a在b中的位置,返回位置索引值原创 2017-08-03 10:55:09 · 4260 阅读 · 3 评论 -
np.cumsum()
import numpy as npa = np.cumsum([[1,2],[2,3]])print(a)#[1 3 5 8],由前面的值依次累加b = np.cumsum([[1,2],[2,3]],axis=0)print(b)#[[1 2]# [3 5]]#每列累加c = np.cumsum([[1,2],[2,3]],axis=1)print(原创 2017-08-03 09:53:55 · 1263 阅读 · 0 评论 -
np.sum
import numpy as npa = np.sum([[1,2],[2,3]])print(a)#8,矩阵中所有元素相加b = np.sum([[1,2],[2,3]],axis=0)print(b)#[3 5],每列之和c = np.sum([[1,2],[4,3]],axis=1)print(c)#[3 7],每行之和d = np.sum([0.5, 0.7,原创 2017-08-03 09:47:59 · 539 阅读 · 0 评论 -
np.random.seed()
import numpy as npnp.random.seed(0)q = np.random.rand(7)np.random.seed(0)p = np.random.rand(7)print(q)print(p)设置相同seed参数得到的随机数一样,若去掉第4行或者改变参数值,得到的随机数不同原创 2017-07-31 14:06:01 · 1005 阅读 · 0 评论 -
初识socket——本地进程间通信实例
服务器端:import socketimport osserver = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)if os.path.exists("/tmp/test.sock"): os.unlink("/tmp/test.sock")server.bind("/tmp/test.sock")server.l原创 2018-01-11 10:32:09 · 2239 阅读 · 0 评论