Python论坛  - 讨论区

标题:[python-chinese] 关于shape

2007年04月27日 星期五 02:44

linda.s samrobertsmith在gmail.com
星期五 四月 27 02:44:51 HKT 2007

我很好奇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]

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年04月27日 星期五 09:32

lubiao lubiao.py在gmail.com
星期五 四月 27 09:32:10 HKT 2007

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)

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年04月27日 星期五 15:36

Ken Lai soulhacker511在163.com
星期五 四月 27 15:36:30 HKT 2007

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行。但是文档里面的例子也是这种写法,所以我个人把他当做特例单独记住。


[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年04月27日 星期五 19:11

Li Qingfeng liqfemail在gmail.com
星期五 四月 27 19:11:57 HKT 2007

²»ÖªµÀÊ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 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年04月27日 星期五 23:26

Ken Lai soulhacker511在163.com
星期五 四月 27 23:26:49 HKT 2007

On Fri, Apr 27, 2007 at 07:11:57PM +0800, Li Qingfeng wrote:
> 不知道是不是我对numpy的使用有问题,用numpy写的神经网络程序速度比C++还是相去甚
> 远,甚至比纯python程序也快不了多少。
python程序运行的速度应该比cpp慢:python是解释性的嘛。至于使用与不使用的速度,我觉得当数据量大了可能会有些优势,不过我没有实际遇到数据量大的情况。:(用numpy是因为对数组操作方便,真是很爽。


[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

如下红色区域有误,请重新填写。

    你的回复:

    请 登录 后回复。还没有在Zeuux哲思注册吗?现在 注册 !

    Zeuux © 2025

    京ICP备05028076号