Ejemplo n.º 1
0
tf_rate_upperbound = conf['training_parameter']['tf_rate_upperbound']
tf_rate_lowerbound = conf['training_parameter']['tf_rate_lowerbound']
tf_decay_step = conf['training_parameter']['tf_decay_step']
seed = conf['training_parameter']['seed']

# Fix random seed
np.random.seed(seed)
torch.manual_seed(seed)
if torch.cuda.is_available():
    torch.cuda.manual_seed_all(seed)

# Load preprocessed LibriSpeech Dataset

train_set = create_dataloader(conf['meta_variable']['data_path'] +
                              '/train.csv',
                              **conf['model_parameter'],
                              **conf['training_parameter'],
                              shuffle=True,
                              training=True)
valid_set = create_dataloader(conf['meta_variable']['data_path'] + '/dev.csv',
                              **conf['model_parameter'],
                              **conf['training_parameter'],
                              shuffle=False,
                              drop_last=True)

idx2char = {}
with open(conf['meta_variable']['data_path'] + '/idx2chap.csv', 'r') as f:
    for line in f:
        if 'idx' in line: continue
        idx2char[int(line.split(',')[0])] = line[:-1].split(',')[1]

# Load pre-trained model if needed
Ejemplo n.º 2
0
training_msg = 'epoch_{:2d}_step_{:3d}_TrLoss_{:.4f}_TrWER_{:.2f}'
epoch_end_msg = 'epoch_{:2d}_TrLoss_{:.4f}_TrWER_{:.2f}_TtLoss_{:.4f}_TtWER_{:.2f}_time_{:.2f}'
verbose_step = conf['training_parameter']['verbose_step']
tf_rate_upperbound = conf['training_parameter']['tf_rate_upperbound']
tf_rate_lowerbound = conf['training_parameter']['tf_rate_lowerbound']

# Load preprocessed LibriSpeech Dataset ( using testing set directly here, replace them with validation set your self)
# X : Padding to shape [num of sample, max_timestep, feature_dim]
# Y : Squeeze repeated label and apply one-hot encoding (preserve 0 for <sos> and 1 for <eos>)
print("Starting")
#X_train, y_train = load_dataset(conf['train_variable']['data_path'])
#X_val, y_val = load_dataset(conf['val_variable']['data_path'])
#X_test, y_test = load_dataset(conf['test_variable']['data_path'])
train_set = create_dataloader(
    data_path="/home/paperspace/Smart_Titles/ASR_Engine/LibriSpeech/train.csv",
    **conf['model_parameter'],
    **conf['training_parameter'],
    shuffle=True)
valid_set = create_dataloader(
    data_path="/home/paperspace/Smart_Titles/ASR_Engine/LibriSpeech/dev.csv",
    **conf['model_parameter'],
    **conf['training_parameter'],
    shuffle=False)
test_set = create_dataloader(
    data_path="/home/paperspace/Smart_Titles/ASR_Engine/LibriSpeech/test.csv",
    **conf['model_parameter'],
    **conf['training_parameter'],
    shuffle=False)
print("Parameters Loaded")
# Construct LAS Model or load pretrained LAS model
if not use_pretrained: