Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
N
NiuTrans.Tensor
概览
Overview
Details
Activity
Cycle Analytics
版本库
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
问题
8
Issues
8
列表
Board
标记
里程碑
合并请求
0
Merge Requests
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
Snippets
成员
Collapse sidebar
Close sidebar
活动
图像
聊天
创建新问题
作业
提交
Issue Boards
Open sidebar
NiuTrans
NiuTrans.Tensor
Commits
e6c92495
Commit
e6c92495
authored
Mar 05, 2021
by
xiaotong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wording
parent
39eef110
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
11 行增加
和
8 行删除
+11
-8
source/tensor/core/getandset/OnehotAndIndex.cpp
+6
-3
source/tensor/core/movement/Gather.cpp
+1
-1
source/tensor/core/shape/Merge.cpp
+4
-4
没有找到文件。
source/tensor/core/getandset/OnehotAndIndex.cpp
查看文件 @
e6c92495
...
...
@@ -96,9 +96,12 @@ XTensor OnehotToIndex(const XTensor & onehot, int size)
/*
convert index tensor to onehot tensor
>> index - index tensor, which value is an integer num
>> onehot - onehot tensor, which value is 0 or 1
>> size - the last dimension size of the onehot tensor
>> index - index of the output dimension (over the vocabulary)
>> onehot - one-hot representation of the index
>> size - vocabuary size (last dimension size of onehot)
>> labelSmoothingP - the parameter that controls how smooth the output is.
E.g., p = 0 means no smoothing
p = 1 means a uniform distribution (almost)
*/
void
_IndexToOnehot
(
const
XTensor
*
index
,
XTensor
*
onehot
,
int
size
,
float
labelSmoothingP
)
...
...
source/tensor/core/movement/Gather.cpp
查看文件 @
e6c92495
...
...
@@ -115,7 +115,7 @@ void _Gather(const XTensor * s, XTensor * t, XTensor * srcIndex)
for
(
int
i
=
0
;
i
<
indexSize
;
i
++
)
{
int
sIndex
=
sIndexData
[
i
]
*
stride
;
CheckNTErrors
(
sIndex
<
s
->
unitNum
,
"Wrong index!"
);
CheckNTErrors
(
sIndex
<
s
->
unitNum
&&
sIndex
>=
0
,
"Wrong index!"
);
for
(
int
j
=
0
;
j
<
stride
;
j
++
)
tData
[
i
*
stride
+
j
]
=
sData
[
sIndex
+
j
];
}
...
...
source/tensor/core/shape/Merge.cpp
查看文件 @
e6c92495
...
...
@@ -185,13 +185,13 @@ bool CheckMergeSize(const XTensor * s, const XTensor * t, int whereToMerge, int
transform a tensor by merging it along with a dimension (return an XTensor structure)
make a new tensor to keep the result and return it
e.g., (
N/3, M, 3) -> (N, M
)
e.g., (
3, M, N/3) -> (M, N
)
>> s - the source tensor
>> whereToMerge - the merging operation is along with which dimension
>> leadingDim - the leading dimension of merging, take (
N/3, M, 3) -> (N, M
)
for example, whereToMerge =
0
(i.e., the dimension for "N/3")
leadingDim =
2
(i.e., the dimension for "3")
>> leadingDim - the leading dimension of merging, take (
3, M, N/3) -> (M, N
)
for example, whereToMerge =
2
(i.e., the dimension for "N/3")
leadingDim =
0
(i.e., the dimension for "3")
<< return - the transformed tensor by merging along with a dimension
*/
XTensor
Merge
(
const
XTensor
&
s
,
int
whereToMerge
,
int
leadingDim
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论