Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
e5d09827
提交
e5d09827
authored
4月 19, 2017
作者:
Frédéric Bastien
提交者:
GitHub
4月 19, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #5853 from Amrithasuresh/master
Updated numpy as np #4218
上级
c82f6e51
3d8ab35a
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
37 行增加
和
37 行删除
+37
-37
__init__.py
theano/__init__.py
+2
-2
configdefaults.py
theano/configdefaults.py
+6
-6
test_params_type.py
theano/gof/tests/test_params_type.py
+12
-12
rng_mrg.py
theano/gpuarray/rng_mrg.py
+2
-2
basic.py
theano/scalar/basic.py
+0
-0
basic_scipy.py
theano/scalar/basic_scipy.py
+11
-11
sharedvar.py
theano/scalar/sharedvar.py
+4
-4
没有找到文件。
theano/__init__.py
浏览文件 @
e5d09827
...
@@ -134,7 +134,7 @@ if (config.device.startswith('cuda') or
...
@@ -134,7 +134,7 @@ if (config.device.startswith('cuda') or
import
theano.gpuarray
import
theano.gpuarray
# Use config.numpy to call numpy.seterr
# Use config.numpy to call numpy.seterr
import
numpy
import
numpy
as
np
if
config
.
numpy
.
seterr_all
==
'None'
:
if
config
.
numpy
.
seterr_all
==
'None'
:
_all
=
None
_all
=
None
...
@@ -156,7 +156,7 @@ if config.numpy.seterr_invalid == 'None':
...
@@ -156,7 +156,7 @@ if config.numpy.seterr_invalid == 'None':
_invalid
=
None
_invalid
=
None
else
:
else
:
_invalid
=
config
.
numpy
.
seterr_invalid
_invalid
=
config
.
numpy
.
seterr_invalid
n
umpy
.
seterr
(
n
p
.
seterr
(
all
=
_all
,
all
=
_all
,
divide
=
_divide
,
divide
=
_divide
,
over
=
_over
,
over
=
_over
,
...
...
theano/configdefaults.py
浏览文件 @
e5d09827
...
@@ -3,7 +3,7 @@ import errno
...
@@ -3,7 +3,7 @@ import errno
import
os
import
os
import
sys
import
sys
import
logging
import
logging
import
numpy
import
numpy
as
np
import
platform
import
platform
import
textwrap
import
textwrap
import
re
import
re
...
@@ -1052,7 +1052,7 @@ AddConfigVar('profiling.ignore_first_call',
...
@@ -1052,7 +1052,7 @@ AddConfigVar('profiling.ignore_first_call',
AddConfigVar
(
'optdb.position_cutoff'
,
AddConfigVar
(
'optdb.position_cutoff'
,
'Where to stop eariler during optimization. It represent the'
'Where to stop eariler during optimization. It represent the'
' position of the optimizer where to stop.'
,
' position of the optimizer where to stop.'
,
FloatParam
(
n
umpy
.
inf
),
FloatParam
(
n
p
.
inf
),
in_c_key
=
False
)
in_c_key
=
False
)
AddConfigVar
(
'optdb.max_use_ratio'
,
AddConfigVar
(
'optdb.max_use_ratio'
,
...
@@ -1106,11 +1106,11 @@ def default_blas_ldflags():
...
@@ -1106,11 +1106,11 @@ def default_blas_ldflags():
global
numpy
global
numpy
warn_record
=
[]
warn_record
=
[]
try
:
try
:
if
(
hasattr
(
n
umpy
.
distutils
,
'__config__'
)
and
if
(
hasattr
(
n
p
.
distutils
,
'__config__'
)
and
n
umpy
.
distutils
.
__config__
):
n
p
.
distutils
.
__config__
):
# If the old private interface is available use it as it
# If the old private interface is available use it as it
# don't print information to the user.
# don't print information to the user.
blas_info
=
n
umpy
.
distutils
.
__config__
.
blas_opt_info
blas_info
=
n
p
.
distutils
.
__config__
.
blas_opt_info
else
:
else
:
# We do this import only here, as in some setup, if we
# We do this import only here, as in some setup, if we
# just import theano and exit, with the import at global
# just import theano and exit, with the import at global
...
@@ -1494,7 +1494,7 @@ compiledir_format_dict = {
...
@@ -1494,7 +1494,7 @@ compiledir_format_dict = {
"python_bitwidth"
:
local_bitwidth
(),
"python_bitwidth"
:
local_bitwidth
(),
"python_int_bitwidth"
:
python_int_bitwidth
(),
"python_int_bitwidth"
:
python_int_bitwidth
(),
"theano_version"
:
theano
.
__version__
,
"theano_version"
:
theano
.
__version__
,
"numpy_version"
:
n
umpy
.
__version__
,
"numpy_version"
:
n
p
.
__version__
,
"gxx_version"
:
gcc_version_str
.
replace
(
" "
,
"_"
),
"gxx_version"
:
gcc_version_str
.
replace
(
" "
,
"_"
),
"hostname"
:
socket
.
gethostname
()}
"hostname"
:
socket
.
gethostname
()}
...
...
theano/gof/tests/test_params_type.py
浏览文件 @
e5d09827
from
__future__
import
absolute_import
,
print_function
,
division
from
__future__
import
absolute_import
,
print_function
,
division
import
theano
import
theano
import
numpy
import
numpy
as
np
from
unittest
import
TestCase
from
unittest
import
TestCase
from
theano.gof
import
Op
,
COp
,
Apply
from
theano.gof
import
Op
,
COp
,
Apply
from
theano
import
Generic
from
theano
import
Generic
...
@@ -121,21 +121,21 @@ class TestParamsType(TestCase):
...
@@ -121,21 +121,21 @@ class TestParamsType(TestCase):
npy_scalar
=
TensorType
(
'float64'
,
tuple
()))
npy_scalar
=
TensorType
(
'float64'
,
tuple
()))
wp2
=
ParamsType
(
a
=
Generic
(),
array
=
TensorType
(
'int64'
,
(
False
,)),
floatting
=
Scalar
(
'float64'
),
wp2
=
ParamsType
(
a
=
Generic
(),
array
=
TensorType
(
'int64'
,
(
False
,)),
floatting
=
Scalar
(
'float64'
),
npy_scalar
=
TensorType
(
'float64'
,
tuple
()))
npy_scalar
=
TensorType
(
'float64'
,
tuple
()))
w1
=
Params
(
wp1
,
a
=
1
,
array
=
n
umpy
.
asarray
([
1
,
2
,
4
,
5
,
7
]),
floatting
=-
4.5
,
npy_scalar
=
numpy
.
asarray
(
12
))
w1
=
Params
(
wp1
,
a
=
1
,
array
=
n
p
.
asarray
([
1
,
2
,
4
,
5
,
7
]),
floatting
=-
4.5
,
npy_scalar
=
np
.
asarray
(
12
))
w2
=
Params
(
wp2
,
a
=
1
,
array
=
n
umpy
.
asarray
([
1
,
2
,
4
,
5
,
7
]),
floatting
=-
4.5
,
npy_scalar
=
numpy
.
asarray
(
12
))
w2
=
Params
(
wp2
,
a
=
1
,
array
=
n
p
.
asarray
([
1
,
2
,
4
,
5
,
7
]),
floatting
=-
4.5
,
npy_scalar
=
np
.
asarray
(
12
))
assert
w1
==
w2
assert
w1
==
w2
assert
not
(
w1
!=
w2
)
assert
not
(
w1
!=
w2
)
assert
hash
(
w1
)
==
hash
(
w2
)
assert
hash
(
w1
)
==
hash
(
w2
)
# Changing attributes names only (a -> other_name).
# Changing attributes names only (a -> other_name).
wp2_other
=
ParamsType
(
other_name
=
Generic
(),
array
=
TensorType
(
'int64'
,
(
False
,)),
floatting
=
Scalar
(
'float64'
),
wp2_other
=
ParamsType
(
other_name
=
Generic
(),
array
=
TensorType
(
'int64'
,
(
False
,)),
floatting
=
Scalar
(
'float64'
),
npy_scalar
=
TensorType
(
'float64'
,
tuple
()))
npy_scalar
=
TensorType
(
'float64'
,
tuple
()))
w2
=
Params
(
wp2_other
,
other_name
=
1
,
array
=
n
umpy
.
asarray
([
1
,
2
,
4
,
5
,
7
]),
floatting
=-
4.5
,
npy_scalar
=
numpy
.
asarray
(
12
))
w2
=
Params
(
wp2_other
,
other_name
=
1
,
array
=
n
p
.
asarray
([
1
,
2
,
4
,
5
,
7
]),
floatting
=-
4.5
,
npy_scalar
=
np
.
asarray
(
12
))
assert
w1
!=
w2
assert
w1
!=
w2
# Changing attributes values only (now a=2).
# Changing attributes values only (now a=2).
w2
=
Params
(
wp2
,
a
=
2
,
array
=
n
umpy
.
asarray
([
1
,
2
,
4
,
5
,
7
]),
floatting
=-
4.5
,
npy_scalar
=
numpy
.
asarray
(
12
))
w2
=
Params
(
wp2
,
a
=
2
,
array
=
n
p
.
asarray
([
1
,
2
,
4
,
5
,
7
]),
floatting
=-
4.5
,
npy_scalar
=
np
.
asarray
(
12
))
assert
w1
!=
w2
assert
w1
!=
w2
# Changing NumPy array values (5 -> -5).
# Changing NumPy array values (5 -> -5).
w2
=
Params
(
wp2
,
a
=
1
,
array
=
n
umpy
.
asarray
([
1
,
2
,
4
,
-
5
,
7
]),
floatting
=-
4.5
,
npy_scalar
=
numpy
.
asarray
(
12
))
w2
=
Params
(
wp2
,
a
=
1
,
array
=
n
p
.
asarray
([
1
,
2
,
4
,
-
5
,
7
]),
floatting
=-
4.5
,
npy_scalar
=
np
.
asarray
(
12
))
assert
w1
!=
w2
assert
w1
!=
w2
def
test_hash_and_eq_params_type
(
self
):
def
test_hash_and_eq_params_type
(
self
):
...
@@ -168,7 +168,7 @@ class TestParamsType(TestCase):
...
@@ -168,7 +168,7 @@ class TestParamsType(TestCase):
def
test_params_type_filtering
(
self
):
def
test_params_type_filtering
(
self
):
shape_tensor5
=
(
1
,
2
,
2
,
3
,
2
)
shape_tensor5
=
(
1
,
2
,
2
,
3
,
2
)
size_tensor5
=
shape_tensor5
[
0
]
*
shape_tensor5
[
1
]
*
shape_tensor5
[
2
]
*
shape_tensor5
[
3
]
*
shape_tensor5
[
4
]
size_tensor5
=
shape_tensor5
[
0
]
*
shape_tensor5
[
1
]
*
shape_tensor5
[
2
]
*
shape_tensor5
[
3
]
*
shape_tensor5
[
4
]
random_tensor
=
n
umpy
.
random
.
normal
(
size
=
size_tensor5
)
.
reshape
(
shape_tensor5
)
random_tensor
=
n
p
.
random
.
normal
(
size
=
size_tensor5
)
.
reshape
(
shape_tensor5
)
w
=
ParamsType
(
a1
=
TensorType
(
'int32'
,
(
False
,
False
)),
w
=
ParamsType
(
a1
=
TensorType
(
'int32'
,
(
False
,
False
)),
a2
=
TensorType
(
'float64'
,
(
False
,
False
,
False
,
False
,
False
)),
a2
=
TensorType
(
'float64'
,
(
False
,
False
,
False
,
False
,
False
)),
...
@@ -176,7 +176,7 @@ class TestParamsType(TestCase):
...
@@ -176,7 +176,7 @@ class TestParamsType(TestCase):
# With a value that does not match the params type.
# With a value that does not match the params type.
o
=
Params
(
w
,
o
=
Params
(
w
,
a1
=
n
umpy
.
asarray
([[
1
,
2
,
3
,
4
,
5
,
6
],
[
7
,
8
,
9
,
10
,
11
,
12
]])
.
astype
(
'int64'
),
a1
=
n
p
.
asarray
([[
1
,
2
,
3
,
4
,
5
,
6
],
[
7
,
8
,
9
,
10
,
11
,
12
]])
.
astype
(
'int64'
),
a2
=
random_tensor
.
astype
(
'float32'
),
a2
=
random_tensor
.
astype
(
'float32'
),
a3
=
2000
)
a3
=
2000
)
# should fail (o.a1 is not int32, o.a2 is not float64)
# should fail (o.a1 is not int32, o.a2 is not float64)
...
@@ -188,7 +188,7 @@ class TestParamsType(TestCase):
...
@@ -188,7 +188,7 @@ class TestParamsType(TestCase):
# With a value that matches the params type.
# With a value that matches the params type.
o1
=
Params
(
w
,
o1
=
Params
(
w
,
a1
=
n
umpy
.
asarray
([[
1
,
2
,
3
,
4
,
5
,
6
],
[
7
,
8
,
9
,
10
,
11
,
12
]])
.
astype
(
'int32'
),
a1
=
n
p
.
asarray
([[
1
,
2
,
3
,
4
,
5
,
6
],
[
7
,
8
,
9
,
10
,
11
,
12
]])
.
astype
(
'int32'
),
a2
=
random_tensor
.
astype
(
'float64'
),
a2
=
random_tensor
.
astype
(
'float64'
),
a3
=
2000
)
a3
=
2000
)
# All should pass.
# All should pass.
...
@@ -198,7 +198,7 @@ class TestParamsType(TestCase):
...
@@ -198,7 +198,7 @@ class TestParamsType(TestCase):
# Check values_eq and values_eq_approx.
# Check values_eq and values_eq_approx.
o2
=
Params
(
w
,
o2
=
Params
(
w
,
a1
=
n
umpy
.
asarray
([[
1
,
2
,
3
,
4
,
5
,
6
],
[
7
,
8
,
9
,
10
,
11
,
12
]])
.
astype
(
'int32'
),
a1
=
n
p
.
asarray
([[
1
,
2
,
3
,
4
,
5
,
6
],
[
7
,
8
,
9
,
10
,
11
,
12
]])
.
astype
(
'int32'
),
a2
=
random_tensor
.
astype
(
'float64'
),
a2
=
random_tensor
.
astype
(
'float64'
),
a3
=
2000
)
a3
=
2000
)
assert
w
.
values_eq
(
o1
,
o2
)
assert
w
.
values_eq
(
o1
,
o2
)
...
@@ -208,7 +208,7 @@ class TestParamsType(TestCase):
...
@@ -208,7 +208,7 @@ class TestParamsType(TestCase):
# NB: I don't know exactly which kind of differences is rejected by values_eq but accepted by values_eq_approx.
# NB: I don't know exactly which kind of differences is rejected by values_eq but accepted by values_eq_approx.
# So, I just play a little with float values.
# So, I just play a little with float values.
o3
=
Params
(
w
,
o3
=
Params
(
w
,
a1
=
n
umpy
.
asarray
([[
1
,
2
,
3
,
4
,
5
,
6
],
[
7
,
8
,
9
,
10
,
11
,
12
]])
.
astype
(
'int32'
),
a1
=
n
p
.
asarray
([[
1
,
2
,
3
,
4
,
5
,
6
],
[
7
,
8
,
9
,
10
,
11
,
12
]])
.
astype
(
'int32'
),
a2
=
(
random_tensor
.
astype
(
'float32'
)
*
10
/
2.2
*
2.19999999999
/
10
)
.
astype
(
'float64'
),
a2
=
(
random_tensor
.
astype
(
'float32'
)
*
10
/
2.2
*
2.19999999999
/
10
)
.
astype
(
'float64'
),
a3
=
2000.0
-
0.00000000000000001
)
a3
=
2000.0
-
0.00000000000000001
)
assert
w
.
values_eq_approx
(
o1
,
o3
)
assert
w
.
values_eq_approx
(
o1
,
o3
)
...
@@ -250,7 +250,7 @@ class TestParamsType(TestCase):
...
@@ -250,7 +250,7 @@ class TestParamsType(TestCase):
f1
=
theano
.
function
([
x
],
y1
)
f1
=
theano
.
function
([
x
],
y1
)
f2
=
theano
.
function
([
x
],
y2
)
f2
=
theano
.
function
([
x
],
y2
)
shape
=
(
100
,
100
)
shape
=
(
100
,
100
)
vx
=
n
umpy
.
random
.
normal
(
size
=
shape
[
0
]
*
shape
[
1
])
.
astype
(
'float64'
)
.
reshape
(
*
shape
)
vx
=
n
p
.
random
.
normal
(
size
=
shape
[
0
]
*
shape
[
1
])
.
astype
(
'float64'
)
.
reshape
(
*
shape
)
vy1
=
f1
(
vx
)
vy1
=
f1
(
vx
)
vy2
=
f2
(
vx
)
vy2
=
f2
(
vx
)
ref
=
a
*
(
vx
**
2
)
+
b
*
vx
+
c
ref
=
a
*
(
vx
**
2
)
+
b
*
vx
+
c
...
...
theano/gpuarray/rng_mrg.py
浏览文件 @
e5d09827
...
@@ -7,7 +7,7 @@ http://www.iro.umontreal.ca/~simardr/ssj/indexe.html
...
@@ -7,7 +7,7 @@ http://www.iro.umontreal.ca/~simardr/ssj/indexe.html
"""
"""
from
__future__
import
absolute_import
,
print_function
,
division
from
__future__
import
absolute_import
,
print_function
,
division
import
numpy
import
numpy
as
np
from
theano
import
Apply
,
tensor
from
theano
import
Apply
,
tensor
from
theano.gof
import
local_optimizer
from
theano.gof
import
local_optimizer
...
@@ -170,7 +170,7 @@ class GPUA_mrg_uniform(GpuKernelBase, mrg_uniform_base):
...
@@ -170,7 +170,7 @@ class GPUA_mrg_uniform(GpuKernelBase, mrg_uniform_base):
o_rstate
,
o_sample
=
out
o_rstate
,
o_sample
=
out
inplace
=
int
(
self
.
inplace
)
inplace
=
int
(
self
.
inplace
)
ndim
=
self
.
output_type
.
ndim
ndim
=
self
.
output_type
.
ndim
o_type_num
=
n
umpy
.
asarray
(
0
,
dtype
=
self
.
output_type
.
dtype
)
.
dtype
.
num
o_type_num
=
n
p
.
asarray
(
0
,
dtype
=
self
.
output_type
.
dtype
)
.
dtype
.
num
fail
=
sub
[
'fail'
]
fail
=
sub
[
'fail'
]
ctx
=
sub
[
'params'
]
ctx
=
sub
[
'params'
]
kname
=
self
.
gpu_kernels
(
node
,
nodename
)[
0
]
.
objvar
kname
=
self
.
gpu_kernels
(
node
,
nodename
)[
0
]
.
objvar
...
...
theano/scalar/basic.py
浏览文件 @
e5d09827
差异被折叠。
点击展开。
theano/scalar/basic_scipy.py
浏览文件 @
e5d09827
...
@@ -2,7 +2,7 @@ from __future__ import absolute_import, print_function, division
...
@@ -2,7 +2,7 @@ from __future__ import absolute_import, print_function, division
# Definitions of theano.scalar ops that have their python implementation taken
# Definitions of theano.scalar ops that have their python implementation taken
# from SciPy. As SciPy is not always available, we treat them separately.
# from SciPy. As SciPy is not always available, we treat them separately.
import
numpy
import
numpy
as
np
import
theano
import
theano
from
theano.gradient
import
grad_not_implemented
from
theano.gradient
import
grad_not_implemented
...
@@ -43,8 +43,8 @@ class Erf(UnaryScalarOp):
...
@@ -43,8 +43,8 @@ class Erf(UnaryScalarOp):
else
:
else
:
return
[
x
.
zeros_like
()]
return
[
x
.
zeros_like
()]
cst
=
n
umpy
.
asarray
(
2.
/
numpy
.
sqrt
(
numpy
.
pi
),
cst
=
n
p
.
asarray
(
2.
/
np
.
sqrt
(
np
.
pi
),
dtype
=
upcast
(
x
.
type
.
dtype
,
gz
.
type
.
dtype
))
dtype
=
upcast
(
x
.
type
.
dtype
,
gz
.
type
.
dtype
))
return
gz
*
cst
*
exp
(
-
x
*
x
),
return
gz
*
cst
*
exp
(
-
x
*
x
),
def
c_code
(
self
,
node
,
name
,
inp
,
out
,
sub
):
def
c_code
(
self
,
node
,
name
,
inp
,
out
,
sub
):
...
@@ -74,8 +74,8 @@ class Erfc(UnaryScalarOp):
...
@@ -74,8 +74,8 @@ class Erfc(UnaryScalarOp):
else
:
else
:
return
[
x
.
zeros_like
()]
return
[
x
.
zeros_like
()]
cst
=
n
umpy
.
asarray
(
2.
/
numpy
.
sqrt
(
numpy
.
pi
),
cst
=
n
p
.
asarray
(
2.
/
np
.
sqrt
(
np
.
pi
),
dtype
=
upcast
(
x
.
type
.
dtype
,
gz
.
type
.
dtype
))
dtype
=
upcast
(
x
.
type
.
dtype
,
gz
.
type
.
dtype
))
return
-
gz
*
cst
*
exp
(
-
x
*
x
),
return
-
gz
*
cst
*
exp
(
-
x
*
x
),
def
c_code
(
self
,
node
,
name
,
inp
,
out
,
sub
):
def
c_code
(
self
,
node
,
name
,
inp
,
out
,
sub
):
...
@@ -120,8 +120,8 @@ class Erfcx(UnaryScalarOp):
...
@@ -120,8 +120,8 @@ class Erfcx(UnaryScalarOp):
else
:
else
:
return
[
x
.
zeros_like
()]
return
[
x
.
zeros_like
()]
cst
=
n
umpy
.
asarray
(
2.
/
numpy
.
sqrt
(
numpy
.
pi
),
cst
=
n
p
.
asarray
(
2.
/
np
.
sqrt
(
np
.
pi
),
dtype
=
upcast
(
x
.
type
.
dtype
,
gz
.
type
.
dtype
))
dtype
=
upcast
(
x
.
type
.
dtype
,
gz
.
type
.
dtype
))
return
gz
*
(
-
cst
+
(
2.
*
x
)
*
erfcx
(
x
)),
return
gz
*
(
-
cst
+
(
2.
*
x
)
*
erfcx
(
x
)),
erfcx
=
Erfcx
(
upgrade_to_float_no_complex
,
name
=
'erfcx'
)
erfcx
=
Erfcx
(
upgrade_to_float_no_complex
,
name
=
'erfcx'
)
...
@@ -155,8 +155,8 @@ class Erfinv(UnaryScalarOp):
...
@@ -155,8 +155,8 @@ class Erfinv(UnaryScalarOp):
else
:
else
:
return
[
x
.
zeros_like
()]
return
[
x
.
zeros_like
()]
cst
=
n
umpy
.
asarray
(
numpy
.
sqrt
(
numpy
.
pi
)
/
2.
,
cst
=
n
p
.
asarray
(
np
.
sqrt
(
np
.
pi
)
/
2.
,
dtype
=
upcast
(
x
.
type
.
dtype
,
gz
.
type
.
dtype
))
dtype
=
upcast
(
x
.
type
.
dtype
,
gz
.
type
.
dtype
))
return
gz
*
cst
*
exp
(
erfinv
(
x
)
**
2
),
return
gz
*
cst
*
exp
(
erfinv
(
x
)
**
2
),
# TODO: erfinv() is not provided by the C standard library
# TODO: erfinv() is not provided by the C standard library
...
@@ -188,8 +188,8 @@ class Erfcinv(UnaryScalarOp):
...
@@ -188,8 +188,8 @@ class Erfcinv(UnaryScalarOp):
else
:
else
:
return
[
x
.
zeros_like
()]
return
[
x
.
zeros_like
()]
cst
=
n
umpy
.
asarray
(
numpy
.
sqrt
(
numpy
.
pi
)
/
2.
,
cst
=
n
p
.
asarray
(
np
.
sqrt
(
np
.
pi
)
/
2.
,
dtype
=
upcast
(
x
.
type
.
dtype
,
gz
.
type
.
dtype
))
dtype
=
upcast
(
x
.
type
.
dtype
,
gz
.
type
.
dtype
))
return
-
gz
*
cst
*
exp
(
erfcinv
(
x
)
**
2
),
return
-
gz
*
cst
*
exp
(
erfcinv
(
x
)
**
2
),
# TODO: erfcinv() is not provided by the C standard library
# TODO: erfcinv() is not provided by the C standard library
...
...
theano/scalar/sharedvar.py
浏览文件 @
e5d09827
...
@@ -16,7 +16,7 @@ way (as scan does) to create a shared variable of this kind.
...
@@ -16,7 +16,7 @@ way (as scan does) to create a shared variable of this kind.
"""
"""
from
__future__
import
absolute_import
,
print_function
,
division
from
__future__
import
absolute_import
,
print_function
,
division
import
numpy
import
numpy
as
np
from
six
import
integer_types
from
six
import
integer_types
from
theano.compile
import
SharedVariable
from
theano.compile
import
SharedVariable
...
@@ -48,15 +48,15 @@ def shared(value, name=None, strict=False, allow_downcast=None):
...
@@ -48,15 +48,15 @@ def shared(value, name=None, strict=False, allow_downcast=None):
We implement this using 0-d tensors for now.
We implement this using 0-d tensors for now.
"""
"""
if
not
isinstance
(
value
,
(
n
umpy
.
number
,
float
,
integer_types
,
complex
)):
if
not
isinstance
(
value
,
(
n
p
.
number
,
float
,
integer_types
,
complex
)):
raise
TypeError
()
raise
TypeError
()
try
:
try
:
dtype
=
value
.
dtype
dtype
=
value
.
dtype
except
AttributeError
:
except
AttributeError
:
dtype
=
n
umpy
.
asarray
(
value
)
.
dtype
dtype
=
n
p
.
asarray
(
value
)
.
dtype
dtype
=
str
(
dtype
)
dtype
=
str
(
dtype
)
value
=
getattr
(
n
umpy
,
dtype
)(
value
)
value
=
getattr
(
n
p
,
dtype
)(
value
)
scalar_type
=
Scalar
(
dtype
=
dtype
)
scalar_type
=
Scalar
(
dtype
=
dtype
)
rval
=
ScalarSharedVariable
(
rval
=
ScalarSharedVariable
(
type
=
scalar_type
,
type
=
scalar_type
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论