CMRC Metric

F1

# find longest common string
def find_lcs(s1, s2):
    m = [[0 for i in range(len(s2)+1)] for j in range(len(s1)+1)]
    mmax = 0
    p = 0
    for i in range(len(s1)):
        for j in range(len(s2)):
            if s1[i] == s2[j]:
                m[i+1 …
more ...


Deploy model in production

Date Tags Tools

Install wsgi using code

git clone https://github.com/GrahamDumpleton/mod_wsgi

apt-get install apache2-dev

apt-get install python-dev

cd mod_wsgi/

./configure

make

make install

Install wsgi using pip

apt-get install libapache2-mod-wsgi-py3 instead of libapache2-mod-wsgi for python3

mod_wsgi install

Load wsgi module in Ubuntu

How do I use a …

more ...


Pytorch Transformer

content

    pytorch transformer

    illustrated transformer

    import math
    import torch
    import torch.nn as nn
    from torch.nn import TransformerEncoder, TransformerEncoderLayer, TransformerDecoder, TransformerDecoderLayer
    from layers.encoder import CustomEmbedding
    import layers
    
    
    class PositionalEncoding(nn.Module):
        """
        Args:
            d_model: the number of expected features in the input (required).
            dropout: the dropout value (default …
    more ...



    Pytorch distributed train

    主卡线程暴涨

    异常:

    master

    正常:

    ma

    def to_var(x, on_cpu=False, gpu_id=None):
        """Tensor => Variable"""
        if torch.cuda.is_available() and not on_cpu:
            x = x.cuda(gpu_id, non_blocking=True)
            # x = Variable(x)
        return x
    
    def normal_kl_div(mu1, var1 …
    more ...