提交 7bd463da authored 作者: abalkin's avatar abalkin

Replace relative imports with absolute.

This is one of the trickier relative to absolute convertions. Some of the initialization code had to be moved from tensor subpackage to the main theano __init__.py in order to work around a circular dependency.
上级 ebee1fb0
...@@ -176,3 +176,13 @@ def test(**kwds): ...@@ -176,3 +176,13 @@ def test(**kwds):
" It is needed for Theano tests.") " It is needed for Theano tests.")
else: else:
return TheanoNoseTester().test(**kwds) return TheanoNoseTester().test(**kwds)
# This cannot be done in tensor/__init__.py due to a circular dependency -- randomstreams
# depends on raw_random which depends on tensor. As a work-around, we import RandomStreams
# here and inject an instance in tensor.
from theano import tensor
from theano.tensor.randomstreams import RandomStreams
# Imitate the numpy.random symbol with a tensor.random one
tensor.random = RandomStreams(seed=0xBAD5EED, no_warn=True)
del RandomStreams
__import__('theano.tensor.shared_randomstreams')
\ No newline at end of file
...@@ -12,14 +12,16 @@ from theano.tensor import blas_scipy ...@@ -12,14 +12,16 @@ from theano.tensor import blas_scipy
from theano.tensor import blas_c from theano.tensor import blas_c
from theano.tensor import xlogx from theano.tensor import xlogx
from theano.tensor import raw_random # These imports cannot be performed here because the modules depend on tensor. This is done at the
from theano.tensor import randomstreams # end of theano.__init__.py instead.
from theano.tensor import shared_randomstreams #from theano.tensor import raw_random
from theano.tensor.randomstreams import \ #from theano.tensor import randomstreams
RandomStreams #from theano.tensor import shared_randomstreams
#from theano.tensor.randomstreams import \
random = RandomStreams(seed=0xBAD5EED, no_warn = True) # RandomStreams
"""Imitate the numpy.random symbol with a tensor.random one"""
#random = RandomStreams(seed=0xBAD5EED, no_warn = True)
#"""Imitate the numpy.random symbol with a tensor.random one"""
from theano.tensor.elemwise import DimShuffle, Elemwise, CAReduce from theano.tensor.elemwise import DimShuffle, Elemwise, CAReduce
......
...@@ -7,8 +7,8 @@ import numpy ...@@ -7,8 +7,8 @@ import numpy
#local imports #local imports
import theano import theano
import basic as tensor from theano import tensor
import opt from theano.tensor import opt
from theano import gof from theano import gof
from theano.compile import optdb from theano.compile import optdb
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论