Output.h 1.47 KB
Newer Older
liyinqiao committed
1 2
/* NiuTrans.NMT - an open-source neural machine translation system.
 * Copyright (C) 2020 NiuTrans Research. All rights reserved.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * $Created by: XIAO Tong (xiaotong@mail.neu.edu.cn) 2018-07-31
liyinqiao committed
19
 * $Modified by: HU Chi (huchinlp@gmail.com) 2020-04
20 21
 */

liyinqiao committed
22 23
#ifndef __OUTPUT_H__
#define __OUTPUT_H__
24

liyinqiao committed
25 26
#include "../Utility.h"
#include "../../../tensor/function/FHeader.h"
27 28 29

using namespace nts;

liyinqiao committed
30
namespace nmt
31 32 33
{

/* output layer */
liyinqiao committed
34
class Output
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
{
public:
    /* device id */
    int devID;

    /* vocabulary size */
    int vSize;

    /* vector size of the linear transformation */
    int hSize;

    /* transformation matrix */
    XTensor w;

public:
    /* constructor */
liyinqiao committed
51
    Output();
52 53

    /* de-constructor */
liyinqiao committed
54
    ~Output();
55 56

    /* initialize the model */
liyinqiao committed
57
    void InitModel(Config& config);
58 59

    /* make the network (redefined output tensor) */
liyinqiao committed
60
    void Make(XTensor& input, XTensor& output, bool isTraining, bool normalized);
61 62 63 64 65
};

}

#endif