Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
a7660331a
tesseract
提交
4ac3063c
T
tesseract
项目概览
a7660331a
/
tesseract
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
tesseract
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
4ac3063c
编写于
4月 27, 2018
作者:
S
Sebastian Buchwald
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add missing override specifiers
上级
37d2088d
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
57 addition
and
60 deletion
+57
-60
src/lstm/fullyconnected.h
src/lstm/fullyconnected.h
+15
-16
src/lstm/lstm.h
src/lstm/lstm.h
+15
-16
src/lstm/plumbing.h
src/lstm/plumbing.h
+16
-16
src/lstm/series.h
src/lstm/series.h
+11
-12
未找到文件。
src/lstm/fullyconnected.h
浏览文件 @
4ac3063c
...
...
@@ -32,9 +32,9 @@ class FullyConnected : public Network {
// Returns the shape output from the network given an input shape (which may
// be partially unknown ie zero).
virtual
StaticShape
OutputShape
(
const
StaticShape
&
input_shape
)
const
;
StaticShape
OutputShape
(
const
StaticShape
&
input_shape
)
const
override
;
virtual
STRING
spec
()
const
{
STRING
spec
()
const
override
{
STRING
spec
;
if
(
type_
==
NT_TANH
)
spec
.
add_str_int
(
"Ft"
,
no_
);
...
...
@@ -63,31 +63,31 @@ class FullyConnected : public Network {
// Suspends/Enables training by setting the training_ flag. Serialize and
// DeSerialize only operate on the run-time data if state is false.
v
irtual
void
SetEnableTraining
(
TrainingState
state
)
;
v
oid
SetEnableTraining
(
TrainingState
state
)
override
;
// Sets up the network for training. Initializes weights using weights of
// scale `range` picked according to the random number generator `randomizer`.
virtual
int
InitWeights
(
float
range
,
TRand
*
randomizer
)
;
int
InitWeights
(
float
range
,
TRand
*
randomizer
)
override
;
// Recursively searches the network for softmaxes with old_no outputs,
// and remaps their outputs according to code_map. See network.h for details.
int
RemapOutputs
(
int
old_no
,
const
std
::
vector
<
int
>&
code_map
)
override
;
// Converts a float network to an int network.
v
irtual
void
ConvertToInt
()
;
v
oid
ConvertToInt
()
override
;
// Provides debug output on the weights.
v
irtual
void
DebugWeights
()
;
v
oid
DebugWeights
()
override
;
// Writes to the given file. Returns false in case of error.
virtual
bool
Serialize
(
TFile
*
fp
)
const
;
bool
Serialize
(
TFile
*
fp
)
const
override
;
// Reads from the given file. Returns false in case of error.
virtual
bool
DeSerialize
(
TFile
*
fp
)
;
bool
DeSerialize
(
TFile
*
fp
)
override
;
// Runs forward propagation of activations on the input line.
// See Network for a detailed discussion of the arguments.
v
irtual
v
oid
Forward
(
bool
debug
,
const
NetworkIO
&
input
,
const
TransposedArray
*
input_transpose
,
NetworkScratch
*
scratch
,
NetworkIO
*
output
)
;
void
Forward
(
bool
debug
,
const
NetworkIO
&
input
,
const
TransposedArray
*
input_transpose
,
NetworkScratch
*
scratch
,
NetworkIO
*
output
)
override
;
// Components of Forward so FullyConnected can be reused inside LSTM.
void
SetupForward
(
const
NetworkIO
&
input
,
const
TransposedArray
*
input_transpose
);
...
...
@@ -97,9 +97,8 @@ class FullyConnected : public Network {
// Runs backward propagation of errors on the deltas line.
// See Network for a detailed discussion of the arguments.
virtual
bool
Backward
(
bool
debug
,
const
NetworkIO
&
fwd_deltas
,
NetworkScratch
*
scratch
,
NetworkIO
*
back_deltas
);
bool
Backward
(
bool
debug
,
const
NetworkIO
&
fwd_deltas
,
NetworkScratch
*
scratch
,
NetworkIO
*
back_deltas
)
override
;
// Components of Backward so FullyConnected can be reused inside LSTM.
void
BackwardTimeStep
(
const
NetworkIO
&
fwd_deltas
,
int
t
,
double
*
curr_errors
,
TransposedArray
*
errors_t
,
double
*
backprop
);
...
...
@@ -112,8 +111,8 @@ class FullyConnected : public Network {
// Sums the products of weight updates in *this and other, splitting into
// positive (same direction) in *same and negative (different direction) in
// *changed.
v
irtual
v
oid
CountAlternators
(
const
Network
&
other
,
double
*
same
,
double
*
changed
)
const
;
void
CountAlternators
(
const
Network
&
other
,
double
*
same
,
double
*
changed
)
const
override
;
protected:
// Weight arrays of size [no, ni + 1].
...
...
src/lstm/lstm.h
浏览文件 @
4ac3063c
...
...
@@ -53,9 +53,9 @@ class LSTM : public Network {
// Returns the shape output from the network given an input shape (which may
// be partially unknown ie zero).
virtual
StaticShape
OutputShape
(
const
StaticShape
&
input_shape
)
const
;
StaticShape
OutputShape
(
const
StaticShape
&
input_shape
)
const
override
;
virtual
STRING
spec
()
const
{
STRING
spec
()
const
override
{
STRING
spec
;
if
(
type_
==
NT_LSTM
)
spec
.
add_str_int
(
"Lfx"
,
ns_
);
...
...
@@ -71,37 +71,36 @@ class LSTM : public Network {
// Suspends/Enables training by setting the training_ flag. Serialize and
// DeSerialize only operate on the run-time data if state is false.
v
irtual
void
SetEnableTraining
(
TrainingState
state
)
;
v
oid
SetEnableTraining
(
TrainingState
state
)
override
;
// Sets up the network for training. Initializes weights using weights of
// scale `range` picked according to the random number generator `randomizer`.
virtual
int
InitWeights
(
float
range
,
TRand
*
randomizer
)
;
int
InitWeights
(
float
range
,
TRand
*
randomizer
)
override
;
// Recursively searches the network for softmaxes with old_no outputs,
// and remaps their outputs according to code_map. See network.h for details.
int
RemapOutputs
(
int
old_no
,
const
std
::
vector
<
int
>&
code_map
)
override
;
// Converts a float network to an int network.
v
irtual
void
ConvertToInt
()
;
v
oid
ConvertToInt
()
override
;
// Provides debug output on the weights.
v
irtual
void
DebugWeights
()
;
v
oid
DebugWeights
()
override
;
// Writes to the given file. Returns false in case of error.
virtual
bool
Serialize
(
TFile
*
fp
)
const
;
bool
Serialize
(
TFile
*
fp
)
const
override
;
// Reads from the given file. Returns false in case of error.
virtual
bool
DeSerialize
(
TFile
*
fp
)
;
bool
DeSerialize
(
TFile
*
fp
)
override
;
// Runs forward propagation of activations on the input line.
// See Network for a detailed discussion of the arguments.
v
irtual
v
oid
Forward
(
bool
debug
,
const
NetworkIO
&
input
,
const
TransposedArray
*
input_transpose
,
NetworkScratch
*
scratch
,
NetworkIO
*
output
)
;
void
Forward
(
bool
debug
,
const
NetworkIO
&
input
,
const
TransposedArray
*
input_transpose
,
NetworkScratch
*
scratch
,
NetworkIO
*
output
)
override
;
// Runs backward propagation of errors on the deltas line.
// See Network for a detailed discussion of the arguments.
virtual
bool
Backward
(
bool
debug
,
const
NetworkIO
&
fwd_deltas
,
NetworkScratch
*
scratch
,
NetworkIO
*
back_deltas
);
bool
Backward
(
bool
debug
,
const
NetworkIO
&
fwd_deltas
,
NetworkScratch
*
scratch
,
NetworkIO
*
back_deltas
)
override
;
// Updates the weights using the given learning rate, momentum and adam_beta.
// num_samples is used in the adam computation iff use_adam_ is true.
void
Update
(
float
learning_rate
,
float
momentum
,
float
adam_beta
,
...
...
@@ -109,8 +108,8 @@ class LSTM : public Network {
// Sums the products of weight updates in *this and other, splitting into
// positive (same direction) in *same and negative (different direction) in
// *changed.
v
irtual
v
oid
CountAlternators
(
const
Network
&
other
,
double
*
same
,
double
*
changed
)
const
;
void
CountAlternators
(
const
Network
&
other
,
double
*
same
,
double
*
changed
)
const
override
;
// Prints the weights for debug purposes.
void
PrintW
();
// Prints the weight deltas for debug purposes.
...
...
src/lstm/plumbing.h
浏览文件 @
4ac3063c
...
...
@@ -34,40 +34,40 @@ class Plumbing : public Network {
virtual
~
Plumbing
();
// Returns the required shape input to the network.
virtual
StaticShape
InputShape
()
const
{
return
stack_
[
0
]
->
InputShape
();
}
virtual
STRING
spec
()
const
{
StaticShape
InputShape
()
const
override
{
return
stack_
[
0
]
->
InputShape
();
}
STRING
spec
()
const
override
{
return
"Sub-classes of Plumbing must implement spec()!"
;
}
// Returns true if the given type is derived from Plumbing, and thus contains
// multiple sub-networks that can have their own learning rate.
virtual
bool
IsPlumbingType
()
const
{
return
true
;
}
bool
IsPlumbingType
()
const
override
{
return
true
;
}
// Suspends/Enables training by setting the training_ flag. Serialize and
// DeSerialize only operate on the run-time data if state is false.
v
irtual
void
SetEnableTraining
(
TrainingState
state
)
;
v
oid
SetEnableTraining
(
TrainingState
state
)
override
;
// Sets flags that control the action of the network. See NetworkFlags enum
// for bit values.
v
irtual
void
SetNetworkFlags
(
uint32_t
flags
)
;
v
oid
SetNetworkFlags
(
uint32_t
flags
)
override
;
// Sets up the network for training. Initializes weights using weights of
// scale `range` picked according to the random number generator `randomizer`.
// Note that randomizer is a borrowed pointer that should outlive the network
// and should not be deleted by any of the networks.
// Returns the number of weights initialized.
virtual
int
InitWeights
(
float
range
,
TRand
*
randomizer
)
;
int
InitWeights
(
float
range
,
TRand
*
randomizer
)
override
;
// Recursively searches the network for softmaxes with old_no outputs,
// and remaps their outputs according to code_map. See network.h for details.
int
RemapOutputs
(
int
old_no
,
const
std
::
vector
<
int
>&
code_map
)
override
;
// Converts a float network to an int network.
v
irtual
void
ConvertToInt
()
;
v
oid
ConvertToInt
()
override
;
// Provides a pointer to a TRand for any networks that care to use it.
// Note that randomizer is a borrowed pointer that should outlive the network
// and should not be deleted by any of the networks.
v
irtual
void
SetRandomizer
(
TRand
*
randomizer
)
;
v
oid
SetRandomizer
(
TRand
*
randomizer
)
override
;
// Adds the given network to the stack.
virtual
void
AddToStack
(
Network
*
network
);
...
...
@@ -75,7 +75,7 @@ class Plumbing : public Network {
// Sets needs_to_backprop_ to needs_backprop and returns true if
// needs_backprop || any weights in this network so the next layer forward
// can be told to produce backprop for this layer if needed.
virtual
bool
SetupNeedsBackprop
(
bool
needs_backprop
)
;
bool
SetupNeedsBackprop
(
bool
needs_backprop
)
override
;
// Returns an integer reduction factor that the network applies to the
// time sequence. Assumes that any 2-d is already eliminated. Used for
...
...
@@ -83,14 +83,14 @@ class Plumbing : public Network {
// WARNING: if GlobalMinimax is used to vary the scale, this will return
// the last used scale factor. Call it before any forward, and it will return
// the minimum scale factor of the paths through the GlobalMinimax.
virtual
int
XScaleFactor
()
const
;
int
XScaleFactor
()
const
override
;
// Provides the (minimum) x scale factor to the network (of interest only to
// input units) so they can determine how to scale bounding boxes.
v
irtual
void
CacheXScaleFactor
(
int
factor
)
;
v
oid
CacheXScaleFactor
(
int
factor
)
override
;
// Provides debug output on the weights.
v
irtual
void
DebugWeights
()
;
v
oid
DebugWeights
()
override
;
// Returns the current stack.
const
PointerVector
<
Network
>&
stack
()
const
{
...
...
@@ -117,9 +117,9 @@ class Plumbing : public Network {
float
*
LayerLearningRatePtr
(
const
char
*
id
)
const
;
// Writes to the given file. Returns false in case of error.
virtual
bool
Serialize
(
TFile
*
fp
)
const
;
bool
Serialize
(
TFile
*
fp
)
const
override
;
// Reads from the given file. Returns false in case of error.
virtual
bool
DeSerialize
(
TFile
*
fp
)
;
bool
DeSerialize
(
TFile
*
fp
)
override
;
// Updates the weights using the given learning rate, momentum and adam_beta.
// num_samples is used in the adam computation iff use_adam_ is true.
...
...
@@ -128,8 +128,8 @@ class Plumbing : public Network {
// Sums the products of weight updates in *this and other, splitting into
// positive (same direction) in *same and negative (different direction) in
// *changed.
v
irtual
v
oid
CountAlternators
(
const
Network
&
other
,
double
*
same
,
double
*
changed
)
const
;
void
CountAlternators
(
const
Network
&
other
,
double
*
same
,
double
*
changed
)
const
override
;
protected:
// The networks.
...
...
src/lstm/series.h
浏览文件 @
4ac3063c
...
...
@@ -32,9 +32,9 @@ class Series : public Plumbing {
// Returns the shape output from the network given an input shape (which may
// be partially unknown ie zero).
virtual
StaticShape
OutputShape
(
const
StaticShape
&
input_shape
)
const
;
StaticShape
OutputShape
(
const
StaticShape
&
input_shape
)
const
override
;
virtual
STRING
spec
()
const
{
STRING
spec
()
const
override
{
STRING
spec
(
"["
);
for
(
int
i
=
0
;
i
<
stack_
.
size
();
++
i
)
spec
+=
stack_
[
i
]
->
spec
();
...
...
@@ -45,7 +45,7 @@ class Series : public Plumbing {
// Sets up the network for training. Initializes weights using weights of
// scale `range` picked according to the random number generator `randomizer`.
// Returns the number of weights initialized.
virtual
int
InitWeights
(
float
range
,
TRand
*
randomizer
)
;
int
InitWeights
(
float
range
,
TRand
*
randomizer
)
override
;
// Recursively searches the network for softmaxes with old_no outputs,
// and remaps their outputs according to code_map. See network.h for details.
int
RemapOutputs
(
int
old_no
,
const
std
::
vector
<
int
>&
code_map
)
override
;
...
...
@@ -53,7 +53,7 @@ class Series : public Plumbing {
// Sets needs_to_backprop_ to needs_backprop and returns true if
// needs_backprop || any weights in this network so the next layer forward
// can be told to produce backprop for this layer if needed.
virtual
bool
SetupNeedsBackprop
(
bool
needs_backprop
)
;
bool
SetupNeedsBackprop
(
bool
needs_backprop
)
override
;
// Returns an integer reduction factor that the network applies to the
// time sequence. Assumes that any 2-d is already eliminated. Used for
...
...
@@ -61,23 +61,22 @@ class Series : public Plumbing {
// WARNING: if GlobalMinimax is used to vary the scale, this will return
// the last used scale factor. Call it before any forward, and it will return
// the minimum scale factor of the paths through the GlobalMinimax.
virtual
int
XScaleFactor
()
const
;
int
XScaleFactor
()
const
override
;
// Provides the (minimum) x scale factor to the network (of interest only to
// input units) so they can determine how to scale bounding boxes.
v
irtual
void
CacheXScaleFactor
(
int
factor
)
;
v
oid
CacheXScaleFactor
(
int
factor
)
override
;
// Runs forward propagation of activations on the input line.
// See Network for a detailed discussion of the arguments.
v
irtual
v
oid
Forward
(
bool
debug
,
const
NetworkIO
&
input
,
const
TransposedArray
*
input_transpose
,
NetworkScratch
*
scratch
,
NetworkIO
*
output
)
;
void
Forward
(
bool
debug
,
const
NetworkIO
&
input
,
const
TransposedArray
*
input_transpose
,
NetworkScratch
*
scratch
,
NetworkIO
*
output
)
override
;
// Runs backward propagation of errors on the deltas line.
// See Network for a detailed discussion of the arguments.
virtual
bool
Backward
(
bool
debug
,
const
NetworkIO
&
fwd_deltas
,
NetworkScratch
*
scratch
,
NetworkIO
*
back_deltas
);
bool
Backward
(
bool
debug
,
const
NetworkIO
&
fwd_deltas
,
NetworkScratch
*
scratch
,
NetworkIO
*
back_deltas
)
override
;
// Splits the series after the given index, returning the two parts and
// deletes itself. The first part, up to network with index last_start, goes
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录