util.py 1.3 KB
Newer Older
L
Li Fuchen 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13
#   Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.
#
# 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.
14
"""
Y
Yibing Liu 已提交
15 16 17
Utils
"""

Y
Yibing Liu 已提交
18
import six
Y
Yibing Liu 已提交
19
import os
Y
Yibing Liu 已提交
20 21


Y
Yibing Liu 已提交
22
def print_arguments(args):
Y
Yibing Liu 已提交
23 24 25
    """
    Print arguments
    """
Y
Yibing Liu 已提交
26
    print('-----------  Configuration Arguments -----------')
Y
Yibing Liu 已提交
27
    for arg, value in sorted(six.iteritems(vars(args))):
Y
Yibing Liu 已提交
28 29 30 31
        print('%s: %s' % (arg, value))
    print('------------------------------------------------')


Y
Yibing Liu 已提交
32
def mkdir(path):
Y
Yibing Liu 已提交
33 34 35
    """
    Mkdir
    """
L
Li Fuchen 已提交
36
    if not os.path.isdir(path):
37 38
        if os.path.split(path)[0]:
            mkdir(os.path.split(path)[0])
Y
Yibing Liu 已提交
39 40 41 42 43
    else:
        return
    os.mkdir(path)


Y
Yibing Liu 已提交
44
def pos_encoding_init():
Y
Yibing Liu 已提交
45 46 47
    """
    Pos encoding init
    """
Y
Yibing Liu 已提交
48 49 50 51
    pass


def scaled_dot_product_attention():
Y
Yibing Liu 已提交
52 53 54
    """
    Scaleed dot product attention
    """
Y
Yibing Liu 已提交
55
    pass