Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
d084cecf
提交
d084cecf
authored
10月 17, 2014
作者:
Frederic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
small update
上级
dd018d55
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
3 行增加
和
34 行删除
+3
-34
basic.txt
doc/library/tensor/basic.txt
+0
-0
basic.py
theano/tensor/basic.py
+3
-34
没有找到文件。
doc/library/tensor/basic.txt
浏览文件 @
d084cecf
theano/tensor/basic.py
浏览文件 @
d084cecf
...
@@ -5095,19 +5095,13 @@ def swapaxes(y, axis1, axis2):
...
@@ -5095,19 +5095,13 @@ def swapaxes(y, axis1, axis2):
def
choose
(
a
,
choices
,
out
=
None
,
mode
=
'raise'
):
def
choose
(
a
,
choices
,
out
=
None
,
mode
=
'raise'
):
# This is done to keep the same function signature then NumPy.
assert
out
is
None
assert
out
is
None
return
Choose
(
mode
)(
a
,
choices
)
return
Choose
(
mode
)(
a
,
choices
)
class
Choose
(
Op
):
def
__init__
(
self
,
mode
):
self
.
mode
=
mode
def
__hash__
(
self
):
return
hash
((
type
(
self
),
self
.
props
()))
def
__eq__
(
self
,
other
):
class
Choose
(
Op
):
return
(
type
(
self
)
==
type
(
other
)
and
self
.
props
()
==
other
.
props
()
)
__props__
=
(
'mode'
,
)
def
infer_shape
(
self
,
node
,
shapes
):
def
infer_shape
(
self
,
node
,
shapes
):
if
isinstance
(
node
.
inputs
[
1
],
tuple
):
if
isinstance
(
node
.
inputs
[
1
],
tuple
):
...
@@ -5118,9 +5112,6 @@ class Choose(Op):
...
@@ -5118,9 +5112,6 @@ class Choose(Op):
else
:
else
:
return
[(
shapes
[
0
])]
return
[(
shapes
[
0
])]
def
props
(
self
):
return
self
.
mode
def
make_node
(
self
,
a
,
choices
):
def
make_node
(
self
,
a
,
choices
):
from
theano
import
typed_list
from
theano
import
typed_list
a
=
as_tensor_variable
(
a
)
a
=
as_tensor_variable
(
a
)
...
@@ -5134,25 +5125,3 @@ class Choose(Op):
...
@@ -5134,25 +5125,3 @@ class Choose(Op):
a
=
inputs
[
0
]
a
=
inputs
[
0
]
choice
=
inputs
[
1
]
choice
=
inputs
[
1
]
z
[
0
]
=
numpy
.
choose
(
a
,
choice
,
mode
=
self
.
mode
)
z
[
0
]
=
numpy
.
choose
(
a
,
choice
,
mode
=
self
.
mode
)
"""
import theano
from theano import tensor as T
from theano import function
from theano.tensor.basic import choose
import numpy as np
x = T.tensor4(dtype='int64')
y = T.tensor4(dtype='int64')
z = T.tensor4(dtype='int64')
p = T.tensor4(dtype='int64')
w = choose(x,(y,z,p))
f = function([x,y,z,p], w)
a = np.array([0, 1, 2]).reshape((3,1,1,1))
c1 = np.array([1, 2, 3]).reshape((1,3,1,1))
c2 = np.array([-1, -2, -3, -4, -5]).reshape((1,1,5,1))
c3 = np.array([1, 2, 4]).reshape((1,1,1,3))
"""
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论