text_plain_output_1.png
from absl import flags

from gezi import tqdm

import gezi

import glob

import os

from IPython.display import display
import tensorflow as tf
import torch
from absl import flags
FLAGS = flags.FLAGS
from transformers import AutoTokenizer
from datasets import Dataset
from src import config
from src.util import *
from src.get_preds import *
from src.eval import *
import melt as mt
import numpy as np
import glob
import gc
from numba import cuda
from gezi import tqdm
import gezi
import husky
import lele

gezi.init_flags()
model_root = '../input'
model_dirs = [x for x in glob.glob(f'{model_root}/feedback-model*') if os.path.isdir(x)]
model_dirs = [f'../input/feedback-model{i}' for i in range(len(model_dirs))]
model_dir = model_dirs[0]

tf_models = []
first_models = []
ic(first_models)
model_dirs = gezi.unique_list([*tf_models, *first_models, *model_dirs])
m = model_dirs
used_model_indexes = list(range(len(model_dirs)))
used_model_indexes = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 17]
used_model_indexes = [23]
model_dirs = [m[i] for i in used_model_indexes]
used_tf_models = [x for x in model_dirs if x in tf_models]
num_tf_models = len(used_tf_models)

mns = []
for i, model_dir in tqdm(enumerate(model_dirs), total=len(model_dirs)):
    gezi.restore_configs(model_dir)
    mns.append(os.path.basename(FLAGS.model_dir))
    assert 'online' in FLAGS.model_dir
mns

MIN_WEIGHT = 1
weights_dict = {}
weights_dict = {'bart.start.run2': 9, 'roberta.start.nwemb-0': 9, 'deberta.start': 8, 'deberta-xlarge.start': 9, 'deberta-xlarge.end': 9, 'deberta-v3.start.len1024.stride-256.seq_encoder-0': 10, 'deberta-v3.start.len1024.stride-256': 6, 'deberta-v3.start.len1536': 7, 'deberta-v3.start.len1024.rnn_bi': 8, 'deberta-v3.end.len1024.seq_encoder-0': 10, 'deberta-v3.mid.len1024': 8, 'deberta-v3.start.stride-256.seq_encoder-0': 7, 'deberta-v3.start.nwemb-0.mark_end-0': 10, 'deberta-v3.se': 10, 'deberta-v3.se2': 10, 'longformer.start.len1536': 6, 'longformer.start.len1600': 6, 'funnel.start.len1536.bs-8': 6, 'deberta-v3.start.len1024.stride-512': 4, 'electra.start.nwemb-0.run2': 7}
weights_dict0 = {'bart.start.run2': 6, 'deberta-v3.end.len1024.seq_encoder-0': 6, 'deberta-v3.mid.len1024': 4, 'deberta-v3.se': 6, 'deberta-v3.se2': 1, 'deberta-v3.start.len1024.rnn_bi': 5, 'deberta-v3.start.len1024.stride-256': 6, 'deberta-v3.start.len1024.stride-256.seq_encoder-0': 10, 'deberta-v3.start.len1536': 4, 'deberta-v3.start.nwemb-0.mark_end-0': 8, 'deberta-v3.start.stride-256.seq_encoder-0': 9, 'deberta-xlarge.end': 0, 'deberta-xlarge.start': 6, 'deberta.start': 6, 'longformer.start.len1536': 9, 'roberta.start.nwemb-0': 6}
weights_dict1 = {'bart.start.run2': 7, 'deberta-v3.end.len1024.seq_encoder-0': 10, 'deberta-v3.mid.len1024': 6, 'deberta-v3.se': 2, 'deberta-v3.se2': 7, 'deberta-v3.start.len1024.rnn_bi': 8, 'deberta-v3.start.len1024.stride-256': 10, 'deberta-v3.start.len1024.stride-256.seq_encoder-0': 7, 'deberta-v3.start.len1536': 8, 'deberta-v3.start.nwemb-0.mark_end-0': 8, 'deberta-v3.start.stride-256.seq_encoder-0': 7, 'deberta-xlarge.end': 7, 'deberta-xlarge.start': 10, 'deberta.start': 6, 'longformer.start.len1536': 8, 'roberta.start.nwemb-0': 5}
weights_dict2 = {'bart.start.run2': 6, 'deberta-v3.end.len1024.seq_encoder-0': 7, 'deberta-v3.mid.len1024': 5, 'deberta-v3.se': 9, 'deberta-v3.se2': 5, 'deberta-v3.start.len1024.rnn_bi': 9, 'deberta-v3.start.len1024.stride-256': 6, 'deberta-v3.start.len1024.stride-256.seq_encoder-0': 10, 'deberta-v3.start.len1536': 6, 'deberta-v3.start.nwemb-0.mark_end-0': 0, 'deberta-v3.start.stride-256.seq_encoder-0': 5, 'deberta-xlarge.end': 8, 'deberta-xlarge.start': 4, 'deberta.start': 8, 'longformer.start.len1536': 9, 'roberta.start.nwemb-0': 6}
weights_dicts = [weights_dict0, weights_dict1, weights_dict2]
ic(gezi.sort_byval(weights_dict))
len(weights_dict)

def get_weight(x, idx=0):
    weight = 1
    if x in weights_dict:
        return weights_dicts[idx][x]
    return max(weight, 1)
weights = [get_weight(x) for x in mns]
weights2 = [get_weight(x, 1) for x in mns]
weights3 = [get_weight(x, 2) for x in mns]
ic(list(zip(range(len(model_dirs)), model_dirs, mns, weights)), len(model_dirs))