In [1]:
import numpy as np
In [2]:
np.asarray([[1., 2], [3, 4], [5, 6]])
Out[2]:
In [4]:
np.asarray([[1., 2], [3, 4], [5, 6]]).shape
Out[4]:
In [5]:
np.asarray([[1. ,2], [3, 4], [5, 6]])[2, 0]
Out[5]:
In [6]:
a = np.asarray([1.0, 2.0, 3.0])
b = 2.0
a*b
Out[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]:
In [10]:
f(16.3, 12.1)
Out[10]:
In [11]:
from theano import pp
print pp(z)
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]:
In [15]:
f(np.array([[1, 2], [3, 4]]), np.array([[10, 20], [30, 40]]))
Out[15]:
In [20]:
a = T.vector()
out = a + a ** 10
f = function([a], out)
print f([0, 1, 2])
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])
In [ ]: