Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
2a08577a
提交
2a08577a
authored
2月 20, 2016
作者:
RadhikaG
提交者:
Bryn Keller
7月 29, 2016
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Basic implementation of confusion matrix op done.
上级
589b5926
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
63 行增加
和
0 行删除
+63
-0
nnet.py
theano/tensor/nnet/nnet.py
+63
-0
没有找到文件。
theano/tensor/nnet/nnet.py
浏览文件 @
2a08577a
...
@@ -2407,3 +2407,66 @@ class ScalarSoftsign(theano.scalar.UnaryScalarOp):
...
@@ -2407,3 +2407,66 @@ class ScalarSoftsign(theano.scalar.UnaryScalarOp):
scalar_softsign
=
ScalarSoftsign
(
theano
.
scalar
.
upgrade_to_float
,
scalar_softsign
=
ScalarSoftsign
(
theano
.
scalar
.
upgrade_to_float
,
name
=
'scalar_softsign'
)
name
=
'scalar_softsign'
)
softsign
=
elemwise
.
Elemwise
(
scalar_softsign
,
name
=
'softsign'
)
softsign
=
elemwise
.
Elemwise
(
scalar_softsign
,
name
=
'softsign'
)
class
ConfusionMatrix
(
gof
.
Op
):
"""
Computes the confusion matrix of given vectors containing
actual observations and predicted observations.
Parameters
----------
actual : 1-d tensor
pred : 1-d tensor
Returns
-------
conf_mat : Confusion matrix of actual and predictions observations as shown below.
| Predicted
___________|___________
Actual |
|
order : Order of entries in terms of original data
"""
__props__
=
()
def
make_node
(
self
,
actual
,
pred
):
actual
=
tensor
.
as_tensor_variable
(
actual
)
pred
=
tensor
.
as_tensor_variable
(
pred
)
if
actual
.
type
.
ndim
!=
1
:
raise
ValueError
(
'actual must be 1-d tensor'
)
if
pred
.
type
.
ndim
!=
1
:
raise
ValueError
(
'pred must be 1-d tensor'
)
conf
=
tensor
.
TensorType
(
dtype
=
'int64'
,
broadcastable
=
(
False
,
False
))
.
make_variable
()
order
=
actual
.
type
()
node
=
Apply
(
op
=
self
,
inputs
=
[
actual
,
pred
],
outputs
=
[
conf
,
order
])
return
node
def
perform
(
self
,
node
,
input_storage
,
output_storage
):
actual
,
pred
=
input_storage
if
len
(
actual
)
!=
len
(
pred
):
raise
ValueError
(
'Lengths of actual and pred must be the same.'
)
order
=
numpy
.
union1d
(
actual
,
pred
)
order
=
order
[
~
numpy
.
isnan
(
order
)]
colA
=
numpy
.
matrix
(
actual
)
.
T
colP
=
numpy
.
matrix
(
pred
)
.
T
oneHotA
=
colA
.
__eq__
(
order
)
.
astype
(
'int64'
)
oneHotP
=
colP
.
__eq__
(
order
)
.
astype
(
'int64'
)
conf_mat
=
numpy
.
dot
(
oneHotA
.
T
,
oneHotP
)
output_storage
[
0
][
0
]
=
conf_mat
output_storage
[
1
][
0
]
=
order
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论