提交 702a8739 authored 作者: Brandon T. Willard's avatar Brandon T. Willard

Work around Python 3.6 import bug

Python 3.6.x apparently does not properly implement PEP-0221, so `import theano.tensor as tt` does not behave the same as `from theano.tensor as tt` and causes the former to fail for circular imports. This problem does not exist in Python >= 3.7. The relevant Python issues are - https://bugs.python.org/issue23203 - https://bugs.python.org/issue30024
上级 c51f5936
import theano.tensor.basic as tt
# import theano.tensor.basic as tt
from theano import config
from theano.gof.params_type import ParamsType
from theano.scalar import bool as bool_t
# Work-around for Python 3.6 issue that prevents `import theano.tensor as tt`
from theano.tensor import basic as tt
from theano.tensor.opt import in2out
from theano.tensor.blas import ldflags, blas_header_text, blas_header_version
from theano.tensor.blas import blas_optdb, optdb, local_optimizer
......
import numpy as np
import theano
import theano.tensor.basic as tt
# import theano.tensor.basic as tt
from theano import Apply, Op
from theano.gof import local_optimizer
from theano.gof.opt import copy_stack_trace
from theano.scalar import Composite, add, as_common_dtype, mul, sub, true_div
# Work-around for Python 3.6 issue that prevents `import theano.tensor as tt`
from theano.tensor import basic as tt
from theano.tensor import TensorType, as_tensor_variable
from theano.tensor.elemwise import Elemwise
from theano.tensor.opt import register_specialize_device
......
......@@ -18,12 +18,16 @@ import warnings
import numpy as np
import theano
import theano.tensor.basic as tt
# import theano.tensor.basic as tt
from theano import scalar
from theano.compile import optdb
from theano.gof.graph import Apply
from theano.gof.op import Op
# Work-around for Python 3.6 issue that prevents `import theano.tensor as tt`
from theano.tensor import basic as tt
from theano.tensor.opt import (
register_specialize,
register_stabilize,
......
......@@ -14,7 +14,8 @@ import numpy as np
import theano
import theano.scalar.basic as ts
import theano.tensor.basic as tt
# import theano.tensor.basic as tt
from functools import reduce
from collections import defaultdict
......@@ -26,6 +27,10 @@ from theano import (
config,
compile,
) # to register the optimizer built by this file
# Work-around for Python 3.6 issue that prevents `import theano.tensor as tt`
from theano.tensor import basic as tt
from theano.gof import (
opt,
InconsistencyError,
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论