Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
T
Toy-MT-Introduction
概览
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
NiuTrans
Toy-MT-Introduction
Commits
bac2deab
Commit
bac2deab
authored
Sep 25, 2019
by
xiaotong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
InitTensor examples
parent
b3ffcd6e
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
30 行增加
和
6 行删除
+30
-6
Section05-Neural-Networks-and-Language-Modeling/section05-test.tex
+30
-6
没有找到文件。
Section05-Neural-Networks-and-Language-Modeling/section05-test.tex
查看文件 @
bac2deab
...
...
@@ -118,26 +118,50 @@
%%% 定义XTensor
\begin{frame}
{
定义XTensor
}
\begin{itemize}
\item
NiuTensor张量由类XTensor定义
\item
张量由类XTensor表示,利用InitTensor定义,参数:
\begin{itemize}
\item
\textbf
{
必须指定
}
:张量的阶和各个方向维度的大小,关于维度的约定和传统多维数组一样
\item
\textbf
{
可以指定
}
:张量数据类型、稠密程度等等
\item
指向XTensor类型变量的指针
\item
张量的阶
\item
各个方向维度的大小(维度的约定和传统多维数组一样)
\item
张量的数据类型等(有缺省值)
\end{itemize}
\end{itemize}
\vspace
{
-0.4em
}
\begin{tcolorbox}
[enhanced,frame engine=empty,boxrule=0.1mm,size=title,colback=blue!10!white]
\begin{flushleft}
{
\scriptsize
\begin{tabbing}
\texttt
{
XTensor tensor;
}
\hspace
{
12em
}
\=
// 声明张量tensor
\\
\texttt
{
int sizes[3] =
\{
2,3,4
\}
;
}
\>
// 张量的形状为2*3*4
\\
\texttt
{
int sizes[6] =
\{
2,3,4,2,3,4
\}
;
}
\>
// 张量的形状为2*3*4*2*3*4
\\
\texttt
{
InitTensor(
\&
tensor, 6, sizes, X
\_
FLOAT);
}
\>
// 定义形状为sizes的6阶张量
\end{tabbing}
}
\end{flushleft}
\end{tcolorbox}
\texttt
{
InitTensor(
\&
tensor, 3, sizes, X
\_
FLOAT);
}
\>
// 定义形状为sizes的三阶张量
\visible
<2->
{
\begin{itemize}
\item
更简便的定义方式
\end{itemize}
\vspace
{
-0.4em
}
\begin{tcolorbox}
[enhanced,frame engine=empty,boxrule=0.1mm,size=title,colback=blue!10!white]
\begin{flushleft}
{
\scriptsize
\begin{tabbing}
\texttt
{
XTensor a, b, c, d, e;
}
\hspace
{
8.5em
}
\=
// 声明张量tensor
\\
\texttt
{
InitTensor1D(
\&
a, 10, X
\_
FLOAT);
}
\>
// 10维的浮点型向量
\\
\texttt
{
InitTensor1D(
\&
b, 10);
}
\>
// 10维的向量,缺省类型(浮点)
\\
\texttt
{
InitTensor2D(
\&
c, 10, 20);
}
\>
// 10*20的矩阵(缺省为浮点型)
\\
\texttt
{
InitTensor3D(
\&
d, 10, 20, 30, X
\_
INT);
}
\>
// 10*20*30的整型型3阶张量
\\
\texttt
{
InitTensor4D(
\&
e, 10, 20, 30, 40);
}
\>
// 10*20*30*40的4阶张量
\\
\>
// (缺省为浮点型)
\end{tabbing}
}
\end{flushleft}
\end{tcolorbox}
}
\end{frame}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论