Skip to content

Commit 2289c14

Browse files
liuyuuanqingqing01
authored andcommitted
Refine comment for CRF related headers. (#117)
1 parent 332194c commit 2289c14

File tree

2 files changed

+25
-25
lines changed

2 files changed

+25
-25
lines changed

paddle/gserver/layers/CRFLayer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ namespace paddle {
2525
/**
2626
* A layer for calculating the cost of sequential conditional random field
2727
* model.
28-
* See LinearChainCRF.h for the detail of the CRF formulation.
28+
* See class LinearChainCRF for the detail of the CRF formulation.
2929
*/
3030
class CRFLayer : public Layer {
3131
public:

paddle/gserver/layers/LinearChainCRF.h

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -21,39 +21,39 @@ namespace paddle {
2121

2222
class LinearChainCRF {
2323
public:
24-
/*
25-
The size of para and grad must be (numClasses + 2) * numClasses.
26-
The first numClasses values of para are for starting weights (a).
27-
The next numClasses values of para are for ending weights (b),
28-
The remaning values are for transition weights (w).
29-
30-
The probability of a state sequence s of length L is defined as:
31-
P(s) = (1/Z) exp(a_{s_1} + b_{s_L}
32-
+ \sum_{l=1}^L x_{s_l}
33-
+ \sum_{l=2}^L w_{s_{l-1},s_l})
34-
where Z is a normalization value so that the sum of P(s) over all possible
35-
sequences is 1, and x is the input feature to the CRF.
24+
/**
25+
* The size of para and grad must be \f$(numClasses + 2) * numClasses\f$.
26+
* The first numClasses values of para are for starting weights (\f$a\f$).
27+
* The next numClasses values of para are for ending weights (\f$b\f$),
28+
* The remaning values are for transition weights (\f$w\f$).
29+
*
30+
* The probability of a state sequence s of length \f$L\f$ is defined as:
31+
* \f$P(s) = (1/Z) exp(a_{s_1} + b_{s_L}
32+
* + \sum_{l=1}^L x_{s_l}
33+
* + \sum_{l=2}^L w_{s_{l-1},s_l})\f$
34+
* where \f$Z\f$ is a normalization value so that the sum of \f$P(s)\f$ over all possible
35+
* sequences is \f$1\f$, and \f$x\f$ is the input feature to the CRF.
3636
*/
3737
LinearChainCRF(int numClasses, real* para, real* grad);
3838

39-
/*
40-
Calculate the negative log likelihood of s given x.
41-
The size of x must be length * numClasses. Each consecutive numClasses
42-
values are the features for one time step.
39+
/**
40+
* Calculate the negative log likelihood of s given x.
41+
* The size of x must be length * numClasses. Each consecutive numClasses
42+
* values are the features for one time step.
4343
*/
4444
real forward(real* x, int* s, int length);
4545

46-
/*
47-
Calculate the gradient with respect to x, a, b, and w.
48-
The gradient of x will be stored in dx.
49-
backward() can only be called after a corresponding call to forward() with
50-
the same x, s and length.
51-
NOTE: The gradient is added to dx and grad (provided at constructor).
46+
/**
47+
* Calculate the gradient with respect to x, a, b, and w.
48+
* The gradient of x will be stored in dx.
49+
* backward() can only be called after a corresponding call to forward() with
50+
* the same x, s and length.
51+
* @note The gradient is added to dx and grad (provided at constructor).
5252
*/
5353
void backward(real* x, real* dx, int* s, int length);
5454

55-
/*
56-
Find the most probable sequence given x. The result will be stored in s.
55+
/**
56+
* Find the most probable sequence given x. The result will be stored in s.
5757
*/
5858
void decode(real* x, int* s, int length);
5959

0 commit comments

Comments
 (0)