text stringlengths 1 93.6k |
|---|
# Remaining keys will be printed "as is"
|
# (usually in alphabet order)
|
result.update(**data)
|
return dumps(result, default=str)
|
processors = list()
|
# In some cases there is no need to print a timestamp,
|
# because it is already added by an upstream service, such as systemd
|
if log_config.show_datetime is True:
|
processors.append(structlog.processors.TimeStamper(
|
fmt=log_config.datetime_format,
|
utc=log_config.time_in_utc
|
)
|
)
|
# Always add a log level
|
processors.append(structlog.processors.add_log_level)
|
# Render selection: JSON or for output to terminal
|
if log_config.renderer == LogRenderer.JSON:
|
processors.append(structlog.processors.JSONRenderer(serializer=custom_json_serializer))
|
else:
|
processors.append(structlog.dev.ConsoleRenderer(
|
# You can turn off colors in the logs
|
colors=log_config.use_colors_in_console,
|
# You can remove padding in levels, i.e. instead of
|
# [info ] Some info log
|
# [warning] Some warning log
|
# will be
|
# [info] Some info log
|
# [warning] Some warning log
|
pad_level=True
|
))
|
return processors
|
# <FILESEP>
|
#!/usr/bin/env python3 -u
|
# Copyright (c) Facebook, Inc. and its affiliates.
|
#
|
# This source code is licensed under the MIT license found in the
|
# LICENSE file in the root directory of this source tree.
|
"""
|
Train a new model on one or across multiple GPUs.
|
"""
|
import collections
|
import math
|
import random
|
import numpy as np
|
import torch
|
from fairseq import checkpoint_utils, distributed_utils, options, progress_bar, tasks, utils
|
from fairseq.data import iterators
|
from fairseq.trainer import Trainer
|
from fairseq.meters import AverageMeter, StopwatchMeter
|
def main(args, init_distributed=False):
|
utils.import_user_module(args)
|
assert args.max_tokens is not None or args.max_sentences is not None, \
|
'Must specify batch size either with --max-tokens or --max-sentences'
|
# Initialize CUDA and distributed training
|
if torch.cuda.is_available() and not args.cpu:
|
torch.cuda.set_device(args.device_id)
|
torch.manual_seed(args.seed)
|
if init_distributed:
|
args.distributed_rank = distributed_utils.distributed_init(args)
|
if distributed_utils.is_master(args):
|
checkpoint_utils.verify_checkpoint_directory(args.save_dir)
|
#Print args
|
#print(args)
|
# Setup task, e.g., translation, language modeling, etc.
|
#The loading of the text dictionary thing happens in def setup_task in the file sentence_preciction.py
|
task = tasks.setup_task(args)
|
# Load valid dataset (we load training data below, based on the latest checkpoint)
|
for valid_sub_split in args.valid_subset.split(','):
|
task.load_dataset(valid_sub_split, combine=False, epoch=0)
|
# Build model and criterion
|
model = task.build_model(args)
|
criterion = task.build_criterion(args)
|
#print(model)
|
print('| model {}, criterion {}'.format(args.arch, criterion.__class__.__name__))
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.