Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
306ee2c8
提交
306ee2c8
authored
8月 06, 2015
作者:
Iban Harlouchet
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
numpydoc for theano/tensor/sort.py
上级
a8983c95
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
19 行增加
和
13 行删除
+19
-13
sort.py
theano/tensor/sort.py
+19
-13
没有找到文件。
theano/tensor/sort.py
浏览文件 @
306ee2c8
...
@@ -5,7 +5,8 @@ from theano.tensor.basic import mul, arange
...
@@ -5,7 +5,8 @@ from theano.tensor.basic import mul, arange
class
SortOp
(
theano
.
Op
):
class
SortOp
(
theano
.
Op
):
"""
"""
This class is a wrapper for numpy sort function
This class is a wrapper for numpy sort function.
"""
"""
__props__
=
(
"kind"
,
"order"
)
__props__
=
(
"kind"
,
"order"
)
...
@@ -62,12 +63,15 @@ class SortOp(theano.Op):
...
@@ -62,12 +63,15 @@ class SortOp(theano.Op):
return
index_val
return
index_val
def
__get_argsort_indices
(
self
,
a
,
axis
):
def
__get_argsort_indices
(
self
,
a
,
axis
):
"""Calculates indices which can be used to reverse
"""
sorting operation of "a" tensor along "axis"
Calculates indices which can be used to reverse sorting operation of
"a" tensor along "axis".
returns:
Returns
-------
1d array if axis is None
1d array if axis is None
list of lenght len(a.shape) otherwise
list of lenght len(a.shape) otherwise
"""
"""
# The goal is to get gradient wrt input from gradient
# The goal is to get gradient wrt input from gradient
...
@@ -99,24 +103,24 @@ class SortOp(theano.Op):
...
@@ -99,24 +103,24 @@ class SortOp(theano.Op):
def
sort
(
a
,
axis
=-
1
,
kind
=
'quicksort'
,
order
=
None
):
def
sort
(
a
,
axis
=-
1
,
kind
=
'quicksort'
,
order
=
None
):
"""
"""
Return a sorted copy of an array.
Parameters
----------
a : Tensor
a : Tensor
Tensor to be sorted
Tensor to be sorted
axis : Tensor
axis : Tensor
Axis along which to sort. If None, the array is
Axis along which to sort. If None, the array is flattened before
flattened before sorting.
sorting.
kind : {'quicksort', 'mergesort', 'heapsort'}, optional
kind : {'quicksort', 'mergesort', 'heapsort'}, optional
Sorting algorithm. Default is 'quicksort'.
Sorting algorithm. Default is 'quicksort'.
order : list, optional
order : list, optional
When `a` is a structured array, this argument specifies which
When `a` is a structured array, this argument specifies which
fields to compare first, second, and so on. This list does not
fields to compare first, second, and so on. This list does not
need to include all of the fields.
need to include all of the fields.
Returns
-------
A sorted copy of an array.
"""
"""
if
axis
is
None
:
if
axis
is
None
:
a
=
a
.
flatten
()
a
=
a
.
flatten
()
...
@@ -126,7 +130,8 @@ def sort(a, axis=-1, kind='quicksort', order=None):
...
@@ -126,7 +130,8 @@ def sort(a, axis=-1, kind='quicksort', order=None):
class
ArgSortOp
(
theano
.
Op
):
class
ArgSortOp
(
theano
.
Op
):
"""
"""
This class is a wrapper for numpy argsort function
This class is a wrapper for numpy argsort function.
"""
"""
__props__
=
(
"kind"
,
"order"
)
__props__
=
(
"kind"
,
"order"
)
...
@@ -196,6 +201,7 @@ def argsort(a, axis=-1, kind='quicksort', order=None):
...
@@ -196,6 +201,7 @@ def argsort(a, axis=-1, kind='quicksort', order=None):
specified by the kind keyword. It returns an array of indices of
specified by the kind keyword. It returns an array of indices of
the same shape as a that index data along the given axis in sorted
the same shape as a that index data along the given axis in sorted
order.
order.
"""
"""
if
axis
is
None
:
if
axis
is
None
:
a
=
a
.
flatten
()
a
=
a
.
flatten
()
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论