【python error】NameError: name ‘zeros/Float/Array/’ is not defined 【path】

>>> imat = zeros((3,2,1), Float)

Traceback (most recent call last):
File “<pyshell#2>”, line 1, in <module>
imat = zeros((3,2,1), Float)
NameError: name ‘zeros’ is not defined

  • If you import numpy, and numpy contains a zeros() function, then you must call it as numpy.zeros().
  • If you want to refer to zeros() directly, you can from numpy import zeros.

>>> imat = numpy.zeros((3,2,1), Float)

Traceback (most recent call last):
File “<pyshell#5>”, line 1, in <module>
imat = numpy.zeros((3,2,1), Float)
NameError: name ‘Float‘ is not defined

  • The “Float” issue is probably due to changes in puthon/scipy try “float” instead.

NameError: name ‘array’ is not defined

  • import numpy as np
    a = np.array([1,8,3])

NameError: name ‘ArrayType‘ is not defined

np.dtype

current working directory:

>>> import os
>>> os.getcwd()
'/home/user'
>>> os.chdir("/tmp/")
>>> os.getcwd()
'/tmp'

Calculate Matrix Rank using scipy

  • For a tensor, the rank tells you the number of indices (e.g. a scalar is a rank-0 tensor, a vector rank-1 and a matrix rank-2).
  • For linear algebra there is also the definition you cite above. From the docstring, it’s clear that Numpy uses the former.
    • The linear algebra functions are generally grouped in numpy.linalg. (They’re also available fromscipy.linalg, which has more functionality.)
    • You can treat rank-1 arrays as either row or column vectors. dot(A,v) treats v as a column vector, while dot(v,A) treats v as a row vector.
 
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

生活在西班牙

自己动手丰衣足食

BlueAsteroid

Just another WordPress.com site

Jing's Blog

Just another WordPress.com site

Start from here......

我的心情魔方

天才遠私廚

希望能做一個分享各種資訊的好地方

语义噪声

西瓜大丸子汤的博客

笑对人生,傲立寰宇

Just another WordPress.com site

Where On Earth Is Waldo?

A Project By Melanie Coles

the Serious Computer Vision Blog

A blog about computer vision and serious stuff

Cauthy's Blog

paper review...

Cornell Computer Vision Seminar Blog

Blog for CS 7670 - Special Topics in Computer Vision

datarazzi

Life through nerd-colored glasses

Luciana Haill

Brainwaves Augmenting Consciousness

槑烎

1,2,∞

Dr Paul Tennent

and the university of nottingham

turn off the lights, please

A bunch of random, thinned and stateless thoughts around the Web

%d bloggers like this: