2007年04月27日 星期五 02:44
我很好奇shape的 (9,) ,是指9行1列还是1行9列?最后的numarr2好象是1行9列,但是(9,)却好象是要求9行1列?请指教.谢谢! >>> from numpy import * >>> numarr2 array([[ 2, 4, 6], [ 8, 10, 12], [14, 16, 18]]) >>> numarr2.shape = (9,) >>> print numarr2 [ 2 4 6 8 0 12 14 16 18]
2007年04月27日 星期五 09:32
On 4/27/07, linda. s <samrobertsmith at gmail.com> wrote: > 我很好奇shape的 (9,) ,是指9行1列还是1行9列?最后的numarr2好象是1行9列,但是(9,)却好象是要求9行1列?请指教.谢谢! > >>> from numpy import * > >>> numarr2 > array([[ 2, 4, 6], > [ 8, 10, 12], > [14, 16, 18]]) > >>> numarr2.shape = (9,) > >>> print numarr2 > [ 2 4 6 8 0 12 14 16 18] 9行一列 好像应该这样写 numarr2.shape = (9,1) 一行九列 是 numarr2.shape = (1,9)
2007年04月27日 星期五 15:36
On Fri, Apr 27, 2007 at 09:32:10AM +0800, lubiao wrote: > On 4/27/07, linda. s <samrobertsmith在gmail.com> wrote: > > 我很好奇shape的 (9,) ,是指9行1列还是1行9列?最后的numarr2好象是1行9列,但是(9,)却好象是要求9行1列?请指教.谢谢! > > >>> from numpy import * > > >>> numarr2 > > array([[ 2, 4, 6], > > [ 8, 10, 12], > > [14, 16, 18]]) > > >>> numarr2.shape = (9,) > > >>> print numarr2 > > [ 2 4 6 8 0 12 14 16 18] > > > > 9行一列 好像应该这样写 > numarr2.shape = (9,1) > > 一行九列 是 numarr2.shape = (1,9) 这个我也觉得很奇怪,按照文档里面写的应该把(9,)理解成9行。但是文档里面的例子也是这种写法,所以我个人把他当做特例单独记住。
2007年04月27日 星期五 19:11
²»ÖªµÀÊDz»ÊÇÎÒ¶ÔnumpyµÄʹÓÃÓÐÎÊÌ⣬ÓÃnumpyдµÄÉñ¾ÍøÂç³ÌÐòËٶȱÈC++»¹ÊÇÏàÈ¥ÉõÔ¶£¬ÉõÖÁ±È´¿python³ÌÐòÒ²¿ì²»Á˶àÉÙ¡£ ÔÚ07-4-27£¬Ken Lai <soulhacker511在163.com> дµÀ£º > > On Fri, Apr 27, 2007 at 09:32:10AM +0800, lubiao wrote: > > On 4/27/07, linda. s <samrobertsmith在gmail.com> wrote: > > > Î񼆼̮æshapeµÄ (9,) ,ÊÇÖ¸9ÐÐ1Áл¹ÊÇ1ÐÐ9ÁÐ?×îºóµÄnumarr2ºÃÏóÊÇ1ÐÐ9ÁÐ,µ«ÊÇ(9,)È´ºÃÏóÊÇÒªÇó9ÐÐ1ÁÐ?Çë > Ö¸½Ì.лл! > > > >>> from numpy import * > > > >>> numarr2 > > > array([[ 2, 4, 6], > > > [ 8, 10, 12], > > > [14, 16, 18]]) > > > >>> numarr2.shape = (9,) > > > >>> print numarr2 > > > [ 2 4 6 8 0 12 14 16 18] > > > > > > > > 9ÐÐÒ»ÁÐ ºÃÏñÓ¦¸ÃÕâÑùд > > numarr2.shape = (9,1) > > > > Ò»ÐоÅÁÐ ÊÇ numarr2.shape = (1,9) > Õâ¸öÎÒÒ²¾õµÃºÜÆæ¹Ö£¬°´ÕÕÎĵµÀïÃæÐ´µÄÓ¦¸Ã°Ñ(9,)Àí½â³É9ÐС£µ«ÊÇÎĵµÀïÃæµÄÀý×ÓÒ²ÊÇÕâÖÖд·¨£¬ËùÒÔÎÒ¸öÈ˰ÑËûµ±×öÌØÀýµ¥¶À¼Çס¡£ > > _______________________________________________ > python-chinese > Post: send python-chinese在lists.python.cn > Subscribe: send subscribe to python-chinese-request在lists.python.cn > Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn > Detail Info: http://python.cn/mailman/listinfo/python-chinese -------------- 下一部分 -------------- Ò»¸öHTML¸½¼þ±»ÒƳý... URL: http://python.cn/pipermail/python-chinese/attachments/20070427/ab61f449/attachment.html
2007年04月27日 星期五 23:26
On Fri, Apr 27, 2007 at 07:11:57PM +0800, Li Qingfeng wrote: > 不知道是不是我对numpy的使用有问题,用numpy写的神经网络程序速度比C++还是相去甚 > 远,甚至比纯python程序也快不了多少。 python程序运行的速度应该比cpp慢:python是解释性的嘛。至于使用与不使用的速度,我觉得当数据量大了可能会有些优势,不过我没有实际遇到数据量大的情况。:(用numpy是因为对数组操作方便,真是很爽。
Zeuux © 2025
京ICP备05028076号