提交 2207c24f authored 作者: carriepl's avatar carriepl

Merge pull request #3112 from nouiz/numpy_interface

[WIP] Allow numpy.exp(theano_var) to build a graph.
import numpy as np
import theano
import theano.tensor as tt
import theano.tests.unittest_tools as utt
def test_numpy_method():
# This type of code is used frequently by PyMC3 users
x = tt.dmatrix('x')
data = np.random.rand(5, 5)
for fct in [np.exp]:
y = fct(x)
f = theano.function([x], y)
utt.assert_allclose(f(data), fct(data))
......@@ -354,6 +354,10 @@ class _tensor_py_operators:
def diagonal(self, offset=0, axis1=0, axis2=1):
return theano.tensor.basic.diagonal(self, offset, axis1, axis2)
# Elemwise
def exp(self):
return theano.tensor.exp(self)
# CASTING
def astype(self, dtype):
return theano.tensor.cast(self, dtype)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论