コード例 #1
0
ファイル: lm_utils.py プロジェクト: Tahlor/internn
import numpy as np
from general_tools.utils import get_root, get_max_root
ROOT = get_root("internn")
import sys
sys.path.append(str(ROOT))
sys.path.append(str(ROOT / "data"))

print(sys.path)
from internn_utils import *
from pytorch_utils import *
from sen_loader import get_text
from error_measures import *
eps = 1e-7


def sample_to_text(sample, output):
    text = [s.lower() for s in sample["text"]]
    out_text = [
        get_text(o.argmax(-1))[:sample["length"][i]]
        for i, o in enumerate(output)
    ]
    return text, out_text


def cer_index(sample, output, index, **kwargs):
    """

    Args:
        sample:
        output:
        index: 2D array, Batch x indices of preds
コード例 #2
0
ファイル: generate_configs.py プロジェクト: Tahlor/internn
import warnings
from pathlib import Path
import yaml
from itertools import product
import sys
from general_tools.utils import get_root
LM = get_root("lm")
sys.path.append(str(LM / "slurm"))
import gen
from subprocess import Popen

baseline_configs = ["00_master.yaml"]
NAME = "02_REDO"
baseline_configs = [(LM / "configs") / b for b in baseline_configs]
variation_dict = {
    "experiment_type": ["vgg_embeddings"],
    "lm_model_path": ['lm/results/BASE/BERT_EXPERIMENT_TYPE.pt'],
    "embedding_norm": ["softmax"],
    "train_mode2": [
        "single character", "multicharacter USE_CORRECT_CHAR_100",
        "multicharacter MEAN_EMBEDDING_20 RANDOM_CHAR_20 USE_CORRECT_CHAR_20",
        "multicharacter MEAN_EMBEDDING_80 USE_CORRECT_CHAR_20",
        "multicharacter RANDOM_CHAR_80 USE_CORRECT_CHAR_20"
    ]
}

baseline_dict = {"max_intensity": 0}
baseline_dict = False


def cartesian_product(inp):