Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
N
NiuTrans.Tensor
概览
Overview
Details
Activity
Cycle Analytics
版本库
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
问题
0
Issues
0
列表
Board
标记
里程碑
合并请求
0
Merge Requests
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
Snippets
成员
Collapse sidebar
Close sidebar
活动
图像
聊天
创建新问题
作业
提交
Issue Boards
Open sidebar
Emmay
NiuTrans.Tensor
Commits
68e146a6
Commit
68e146a6
authored
Jul 18, 2018
by
xiaotong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix the bug of XLink::params
parent
4b7f7a18
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
18 行增加
和
8 行删除
+18
-8
source/network/XNet.cpp
+2
-0
source/tensor/XLink.cpp
+16
-8
没有找到文件。
source/network/XNet.cpp
查看文件 @
68e146a6
...
@@ -145,6 +145,8 @@ void XNet::Backward(XList &roots, XList &golds, LOSS_FUNCTION_NAME loss)
...
@@ -145,6 +145,8 @@ void XNet::Backward(XList &roots, XList &golds, LOSS_FUNCTION_NAME loss)
XTensor
*
node
=
(
XTensor
*
)
nodes
.
Get
(
i
);
XTensor
*
node
=
(
XTensor
*
)
nodes
.
Get
(
i
);
if
(
node
->
visitMark
==
NODE_FINISHED
)
if
(
node
->
visitMark
==
NODE_FINISHED
)
continue
;
continue
;
BackwardNode
(
node
);
}
}
}
}
...
...
source/tensor/XLink.cpp
查看文件 @
68e146a6
...
@@ -114,6 +114,8 @@ void XLink::ClearOutgoing(XTensor * node)
...
@@ -114,6 +114,8 @@ void XLink::ClearOutgoing(XTensor * node)
outgo
.
ClearTail
();
outgo
.
ClearTail
();
outgo
.
typeID
=
0
;
outgo
.
typeID
=
0
;
outgo
.
type
[
0
]
=
0
;
outgo
.
type
[
0
]
=
0
;
delete
[]
outgo
.
params
;
outgo
.
params
=
NULL
;
}
}
/*
/*
...
@@ -152,6 +154,8 @@ void XLink::ClearIncoming(XTensor * node)
...
@@ -152,6 +154,8 @@ void XLink::ClearIncoming(XTensor * node)
income
.
ClearTail
();
income
.
ClearTail
();
income
.
typeID
=
0
;
income
.
typeID
=
0
;
income
.
type
[
0
]
=
0
;
income
.
type
[
0
]
=
0
;
delete
[]
income
.
params
;
income
.
params
=
NULL
;
}
}
/*
/*
...
@@ -210,7 +214,7 @@ add a parameter
...
@@ -210,7 +214,7 @@ add a parameter
void
XLink
::
AddParam
(
DTYPE
param
)
void
XLink
::
AddParam
(
DTYPE
param
)
{
{
void
*
ps
=
params
;
void
*
ps
=
params
;
params
=
new
char
[
paramNum
+
1
];
params
=
new
char
[
(
paramNum
+
1
)
*
paramSize
];
memcpy
(
params
,
ps
,
paramNum
*
paramSize
);
memcpy
(
params
,
ps
,
paramNum
*
paramSize
);
DTYPE
*
p
=
(
DTYPE
*
)((
char
*
)
params
+
paramNum
*
paramSize
);
DTYPE
*
p
=
(
DTYPE
*
)((
char
*
)
params
+
paramNum
*
paramSize
);
*
p
=
param
;
*
p
=
param
;
...
@@ -226,7 +230,7 @@ add a parameter
...
@@ -226,7 +230,7 @@ add a parameter
void
XLink
::
AddParam
(
void
*
param
,
int
size
)
void
XLink
::
AddParam
(
void
*
param
,
int
size
)
{
{
void
*
ps
=
params
;
void
*
ps
=
params
;
params
=
new
char
[
paramNum
+
1
];
params
=
new
char
[
(
paramNum
+
1
)
*
paramSize
];
memcpy
(
params
,
ps
,
paramNum
*
paramSize
);
memcpy
(
params
,
ps
,
paramNum
*
paramSize
);
char
*
p
=
(
char
*
)
params
+
paramNum
*
paramSize
;
char
*
p
=
(
char
*
)
params
+
paramNum
*
paramSize
;
memcpy
(
p
,
param
,
size
);
memcpy
(
p
,
param
,
size
);
...
@@ -240,6 +244,7 @@ get a paramter in default type
...
@@ -240,6 +244,7 @@ get a paramter in default type
*/
*/
DTYPE
XLink
::
GetParam
(
int
i
)
DTYPE
XLink
::
GetParam
(
int
i
)
{
{
CheckNTErrors
(
params
!=
NULL
,
"parameter array cannot be empty!"
);
char
*
p
=
(
char
*
)
params
+
i
*
paramSize
;
char
*
p
=
(
char
*
)
params
+
i
*
paramSize
;
return
*
(
DTYPE
*
)
p
;
return
*
(
DTYPE
*
)
p
;
}
}
...
@@ -250,6 +255,7 @@ get a paramter in integer
...
@@ -250,6 +255,7 @@ get a paramter in integer
*/
*/
int
XLink
::
GetParamInt
(
int
i
)
int
XLink
::
GetParamInt
(
int
i
)
{
{
CheckNTErrors
(
params
!=
NULL
,
"parameter array cannot be empty!"
);
char
*
p
=
(
char
*
)
params
+
i
*
paramSize
;
char
*
p
=
(
char
*
)
params
+
i
*
paramSize
;
return
*
(
int
*
)
p
;
return
*
(
int
*
)
p
;
}
}
...
@@ -314,8 +320,7 @@ add parameters
...
@@ -314,8 +320,7 @@ add parameters
*/
*/
void
XLink
::
AddParamToHead
(
XTensor
*
h
,
DTYPE
param
)
void
XLink
::
AddParamToHead
(
XTensor
*
h
,
DTYPE
param
)
{
{
if
(
h
!=
NULL
)
CheckNTErrors
(
h
!=
NULL
,
"head tensor cannot be empty!"
);
return
;
h
->
income
.
AddParam
(
param
);
h
->
income
.
AddParam
(
param
);
}
}
...
@@ -326,8 +331,7 @@ add an integer parameter
...
@@ -326,8 +331,7 @@ add an integer parameter
*/
*/
void
XLink
::
AddParamToHeadInt
(
XTensor
*
h
,
int
param
)
void
XLink
::
AddParamToHeadInt
(
XTensor
*
h
,
int
param
)
{
{
if
(
h
!=
NULL
)
CheckNTErrors
(
h
!=
NULL
,
"head tensor cannot be empty!"
);
return
;
h
->
income
.
AddParam
(
&
param
,
sizeof
(
int
));
h
->
income
.
AddParam
(
&
param
,
sizeof
(
int
));
}
}
...
@@ -338,8 +342,7 @@ add a MATRIX_TRANS_TYPE parameter
...
@@ -338,8 +342,7 @@ add a MATRIX_TRANS_TYPE parameter
*/
*/
void
XLink
::
AddParamToHeadTrans
(
XTensor
*
h
,
MATRIX_TRANS_TYPE
param
)
void
XLink
::
AddParamToHeadTrans
(
XTensor
*
h
,
MATRIX_TRANS_TYPE
param
)
{
{
if
(
h
!=
NULL
)
CheckNTErrors
(
h
!=
NULL
,
"head tensor cannot be empty!"
);
return
;
h
->
income
.
AddParam
(
&
param
,
sizeof
(
MATRIX_TRANS_TYPE
));
h
->
income
.
AddParam
(
&
param
,
sizeof
(
MATRIX_TRANS_TYPE
));
}
}
...
@@ -396,6 +399,11 @@ void XLink::Replace(const XTensor * oldOne, XTensor * newOne)
...
@@ -396,6 +399,11 @@ void XLink::Replace(const XTensor * oldOne, XTensor * newOne)
newIncome
.
tailNum
=
oldOne
->
income
.
tailNum
;
newIncome
.
tailNum
=
oldOne
->
income
.
tailNum
;
memcpy
(
newIncome
.
tails
,
oldOne
->
income
.
tails
,
sizeof
(
XTensor
*
)
*
newIncome
.
tailNum
);
memcpy
(
newIncome
.
tails
,
oldOne
->
income
.
tails
,
sizeof
(
XTensor
*
)
*
newIncome
.
tailNum
);
int
paraArraySize
=
oldOne
->
income
.
paramNum
*
oldOne
->
income
.
paramSize
;
newIncome
.
params
=
new
char
[
paraArraySize
];
memcpy
(
newIncome
.
params
,
oldOne
->
income
.
params
,
paraArraySize
);
newIncome
.
paramNum
=
oldOne
->
income
.
paramNum
;
/* update the link to each child node */
/* update the link to each child node */
for
(
int
i
=
0
;
i
<
newIncome
.
tailNum
;
i
++
){
for
(
int
i
=
0
;
i
<
newIncome
.
tailNum
;
i
++
){
XTensor
*
child
=
newIncome
.
tails
[
i
];
XTensor
*
child
=
newIncome
.
tails
[
i
];
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论