axis

tensorflow中tf.argmax和tf.reduce_max

匿名 (未验证) 提交于 2019-12-03 00:22:01
import tensorflow as tf import numpy as np d_scores = {} d_scores[ 0 ] = [[[ 1 , 2 ] , [ 3 , 4 ] , [ 5 , 6 ]] , [[ 7 , 8 ] , [ 9 , 10 ] , [ 11 , 12 ]]] classes = tf.argmax(d_scores[ 0 ] , axis = 1 ) scores = tf.reduce_max(d_scores[ 0 ] , axis = 1 ) with tf.Session() as sess: print (classes.eval()) print (scores.eval()) 结果 [[2 2] import tensorflow as tf import numpy as np d_scores = {} d_scores[ 0 ] = [[[ 1 , 2 ] , [ 3 , 4 ] , [ 5 , 6 ]] , [[ 7 , 8 ] , [ 9 , 10 ] , [ 11 , 12 ]]] classes = tf.argmax(d_scores[ 0 ] , axis = 2 ) scores = tf.reduce_max(d_scores[ 0 ] , axis = 2 ) with tf.Session() as

Nump.concatenate()函数整合问题

匿名 (未验证) 提交于 2019-12-03 00:21:02
c=np.concatenate((a, b), axis=axis) 这个函数用于将多个数组进行连接,这与stack函数很容易混淆,他们之间的区别是concatenate会把当前要匹配的元素降一维,即去掉最外面那一层括号。举个例子: axis=0 a = np.arange(8).reshape(2,2,2)#前面2表示2维 b = np.arange(8).reshape(2,2,2) c=np.concatenate((a, b), axis=axis) d=np.stack((a, b), axis=axis) print(c) print(c.shape) print(d) print(d.shape) 输出 [[[0 1] [2 3]] [[4 5] [6 7]] [[0 1] [2 3]] [[4 5] [6 7]]] (4, 2, 2)#axis=0,扩展为4维 [[[[0 1] [2 3]] [[4 5] [6 7]]] [[[0 1] [2 3]] [[4 5] [6 7]]]] (2, 2, 2, 2) 由此可推: 当axis=1时,c.shape为(2,4,2),整合后C维度不变,行数增加,d.shape为(2,2,2,2) [[[0 1] [2 3] [0 1] [2 3]] [[4 5] [6 7] [4 5] [6 7]]] (2, 4, 2)

深度学习 neural machine translation with attention 错误解析

匿名 (未验证) 提交于 2019-12-03 00:20:01
在这次的 练习中,在 load 过模型参数后,进行 example预测时,报错。 以下是代码部分 EXAMPLES = ['3 May 1979', '5 April 09', '21th of August 2016', 'Tue 10 Jul 2007', 'Saturday May 9 2018', 'March 3 2001', 'March 3rd 2001', '1 March 2001'] for example in EXAMPLES: source = string_to_int(example, Tx, human_vocab) source = np.array(list(map(lambda x: to_categorical(x, num_classes=len(human_vocab)), source))).swapaxes(0,1) prediction = model.predict([source, s0, c0]) prediction = np.argmax(prediction, axis = -1) output = [inv_machine_vocab[int(i)] for i in prediction] print("source:", example) print("output:", ''.join(output))

numpy模块中的sum(axis)方法

匿名 (未验证) 提交于 2019-12-03 00:18:01
1、sum函数声明 sum(a, axis= None , dtype= None , out= None , keepdims=< class ' numpy . _globals . _NoValue '>) 1 参数axis究竟是用来干嘛的? 2、实验 经过我的一些尝试,我发现以下规律: (1) 如果 axis=None 那么就是对所有元素求和: >>> np.sum([[ 0 , 1 ], [ 0 , 5 ], [ 2 , 5 ]], axis= None ) 1 这条语句执行后将会输出: 13 ,把所有元素都进行求和了! (2) 如果 axis=0 那么就是对所有在同一列的元素求和: >>> np.sum([[ 0 , 1 ], [ 0 , 5 ], [ 2 , 5 ]], axis= 0 ) 1 这条语句执行后将会输出: array([ 2, 11]) ,把两列元素都进行求和了! (3) 如果 axis=1 那么就是对所有在同一行的元素求和: >>> np.sum([[ 0 , 1 ], [ 0 , 5 ], [ 2 , 5 ]], axis= 1 ) 1 这条语句执行后将会输出: array([1, 5, 7]) ,把三行元素都进行求和了! (4)如果axis的值 大于1 呢?这样将会 报错 !! >>> np.sum([[ 0 , 1 ], [ 0 , 5 ], [

numpy模块

匿名 (未验证) 提交于 2019-12-03 00:13:02
Ŀ¼ 1) arange 2) linspace/logspace 3) zeros/ones/eye/empty 4) reshape numpy是Python的一种开源的数值扩展库,这种库可用来存储和处理大型numpy数组比Python自身的嵌套列表结构要高效的多(该结构也可以用来表示numpy数组)。 numpy库有两个作用: import numpy as np l1=[1,2,3] l2=[4,5,6] l=[] for i in range(len(l1)): l.append(l1[i]*l2[i]) print(l) arr1=np.array(l1) arr2=np.array(l2) print(arr1*arr2) ''' [4, 10, 18] [ 4 10 18] ''' 如果我们想让l1*l2得到一个结果为[4,10,18]的列表用到了for循环,非常复杂。 numpy数组即numpy的ndarray的对象,创建numpy数组就是把一个列表传入np.array()方法。 # 创建一维的ndarray对象 arr = np.array([1,2,3]) print(arr,type(arr)) [1 2 3] <class 'numpy.ndarray'> #创建二维的ndarray对象 print(np.array([1,2,3],[4,5,6])) '

tf.concat的用法

匿名 (未验证) 提交于 2019-12-03 00:09:02
import numpy as npimport tensorflow as tfsess=tf.Session()a=np.zeros((1,2,3,4))b=np.ones((1,2,3,4))c1 = tf.concat([a, b], axis=-1) # 倒数第一维度增加,其它不变d1=sess.run(c1)print('d1=',d1)print('d1.shape=',d1.shape)c = tf.concat([a, b], axis=-2) #倒数第二维度增加,其它不变d=sess.run(c)print('d=',d)print('d.shape=',d.shape)a1=np.zeros((3,4))b1=np.ones((3,4))c2 = tf.concat([a1, b1], axis=-1) # 如果是二维就和axis=1一样,第2维坐标增加,就是行不变,列增加d2=sess.run(c2)print('d2=',d2)print('d2.shape=',d2.shape) 来源:博客园 作者: tangjunjun 链接:https://www.cnblogs.com/tangjunjun/p/11546250.html

Axis2开发webservice案例详解

眉间皱痕 提交于 2019-12-03 00:06:54
最近公司在一个项目上与另外一家公司做接口集成,需要webservice来处理数据的传递,本来我用的CXF简单配置下就可以发布了(关于CXF发布webservice的过程,在后面的博客中也会给个案例,欢迎扔板儿砖!~_~),但是对方用的是axis,本来以为用wsimport解析下wsdl文件就可以生成客户端程序,然后就可以调用了,后来才发现,解析不了~_~,没办法只能研究下怎么通过axis发布webservice吧! 环境准备: eclipse3.7.2 apache-tomcat-6.0.36 我的目录是:E:\Program Files (x86)\apache-tomcat-6.0.36;一下的tomcat路径都将会沿用这个目录,有时也会用%TOMCAT_HOME%代替 axis1.4 先展示下效果,首先启动tomcat(startup.bat[windows版本]),然后在浏览器上输入: http://localhost:8080/axis/services ,截图如下: ,好了,这里你可以看到有四个无序列表,而且每个后面都还有wsdl链接,简单说下:拿第一个来说 这个是服务名称,先记着,后面会说明。 这个是wsdl描述文件的链接,点进去看下~_~ 3. 好了,介绍完后,开始我们第一个webservice服务的发布吧!!!

tf.nn.softmax 分类

匿名 (未验证) 提交于 2019-12-02 23:49:02
tf.nn.softmax(logits,axis=None,name=None,dim=None) 参数: logits:一个非空的Tensor。必须是下列类型之一:half, float32,float64 axis:将在其上执行维度softmax。默认值为-1,表示最后一个维度 name:操作的名称(可选) dim:axis的已弃用的别名 返回: 一个Tensor,与logits具有相同的类型和shape sample import tensorflow as tf #tf.enable_eager_execution() tf.compat.v1.enable_eager_execution() ones = tf.ones(shape=[2,3]) print(ones) temp1 = tf.nn.softmax(ones,axis=0) # 列 print(temp1) temp2 = tf.nn.softmax(ones,axis=1) # 行 print(temp2) output tf.Tensor( [[1. 1. 1.] [1. 1. 1.]], shape=(2, 3), dtype=float32) tf.Tensor( [[0.5 0.5 0.5] [0.5 0.5 0.5]], shape=(2, 3), dtype=float32) tf

numpy中的delete,insert,append函数

匿名 (未验证) 提交于 2019-12-02 23:47:01
delete numpy.delete(arr,obj,axis=None) arr:输入向量 obj:表明哪一个子向量应该被移除。可以为整数或一个int型的向量 axis:表明删除哪个轴的子向量,若默认,则返回一个被拉平的向量 a = np.array(np.arange(12).reshape(3,4)) a array([[ 0, 1, 2, 3], [ 4, 5, 6, 7], [ 8, 9, 10, 11]]) np.delete(a,1,0) array([[ 0, 1, 2, 3], [ 8, 9, 10, 11]]) np.delete(a,1,1) array([[ 0, 2, 3], [ 4, 6, 7], [ 8, 10, 11]]) np.delete(a,[0,1],1) array([[ 2, 3], [ 6, 7], [10, 11]]) np.delete(a,np.s_[::2],1) array([[ 1, 3], [ 5, 7], [ 9, 11]]) 注意: numpy.s_[::2] 表示选取奇数。 insert numpy.insert(arr,obj,value,axis=None) 同理,value为插入的数值 arr:为目标向量 obj:为目标位置 value:为想要插入的数值 axis:为插入的维度 np.insert(a,1,

Centos 7自定义屏幕分辨率

匿名 (未验证) 提交于 2019-12-02 23:43:01
$ xrandr Screen 0: minimum 1 x 1, current 1680 x 900, maximum 8192 x 8192 Virtual1 connected primary 1680x900+0+0 (normal left inverted right x axis y axis) 0mm x 0mm 800x600 60.00 + 60.32 2560x1600 59.99 1920x1440 60.00 1856x1392 60.00 1792x1344 60.00 1920x1200 59.88 1600x1200 60.00 1680x1050 59.95 1400x1050 59.98 1280x1024 60.02 1440x900 59.89 1280x960 60.00 1360x768 60.02 1280x800 59.81 1152x864 75.00 1280x768 59.87 1024x768 60.00 640x480 59.94 $ cvt 1920 960 60 # 1920x960 59.99 Hz (CVT) hsync: 59.75 kHz; pclk: 152.00 MHz Modeline "1920x960_60.00" 152.00 1920 2032 2232 2544 960 963 973 996