In [1]:
import numpy as np

In [2]:
np.asarray([[1., 2], [3, 4], [5, 6]])


Out[2]:
array([[ 1.,  2.],
       [ 3.,  4.],
       [ 5.,  6.]])

In [4]:
np.asarray([[1., 2], [3, 4], [5, 6]]).shape


Out[4]:
(3L, 2L)

In [5]:
np.asarray([[1. ,2], [3, 4], [5, 6]])[2, 0]


Out[5]:
5.0

In [6]:
a = np.asarray([1.0, 2.0, 3.0])
b = 2.0
a*b


Out[6]:
array([ 2.,  4.,  6.])

In [7]:
import theano.tensor as T
from theano import function
x = T.dscalar('x')
y = T.dscalar('y')
z = x + y
f = function([x, y], z)

In [9]:
f(2, 3)


Out[9]:
array(5.0)

In [10]:
f(16.3, 12.1)


Out[10]:
array(28.4)

In [11]:
from theano import pp
print pp(z)


(x + y)

In [12]:
x = T.dmatrix('x')
y = T.dmatrix('y')
z = x + y
f= function([x, y], z)

In [13]:
f([[1, 2], [3, 4]], [[10, 20], [30, 40]])


Out[13]:
array([[ 11.,  22.],
       [ 33.,  44.]])

In [15]:
f(np.array([[1, 2], [3, 4]]), np.array([[10, 20], [30, 40]]))


Out[15]:
array([[ 11.,  22.],
       [ 33.,  44.]])

In [20]:
a = T.vector()
out = a + a ** 10
f = function([a], out)
print f([0, 1, 2])


[    0.     2.  1026.]

In [28]:
a = T.vector()
b = T.vector()
out = a ** 2 + b ** 2 + 2*a*b
f = function([a, b], out)
print f([1, 2], [4 ,5])


[ 25.  49.]

In [ ]: