# limitations under the License. from __future__ import print_function import os import time import argparse import numpy as np import paddle.fluid as fluid from paddle.fluid.dygraph.base import to_variable import nets import reader from utils import ArgumentGroup from benchmark import AverageMeter, ProgressMeter, Tools parser = argparse.ArgumentParser(__doc__) model_g = ArgumentGroup(parser, "model", "model configuration and paths.") model_g.add_arg("checkpoints", str, "checkpoints", "Path to save checkpoints") train_g = ArgumentGroup(parser, "training", "training options.") train_g.add_arg("epoch", int, 10, "Number of epoches for training.") train_g.add_arg("save_steps", int, 3000, "The steps interval to save checkpoints.") train_g.add_arg("validation_steps", int, 2000, "The steps interval to evaluate model performance.") train_g.add_arg("lr", float, 0.002, "The Learning rate value for training.") train_g.add_arg("padding_size", int, 150, "The padding size for input sequences.") log_g = ArgumentGroup(parser, "logging", "logging related") log_g.add_arg("skip_steps", int, 10, "The steps interval to print loss.") log_g.add_arg("verbose", bool, False, "Whether to output verbose log")
# sys.path.append("../models/classification/") from nets import textcnn_net_multi_label import paddle import paddle.fluid as fluid from utils import ArgumentGroup, print_arguments, DataProcesser, DataReader, ConfigReader from utils import init_checkpoint, check_version, logger import random import codecs import logging import math np.random.seed(0) random.seed(0) parser = argparse.ArgumentParser(__doc__) DEV_COUNT = 1 model_g = ArgumentGroup(parser, "model", "model configuration and paths.") model_g.add_arg("init_checkpoint", str, None, "Init checkpoint to resume training from.") model_g.add_arg("checkpoints", str, "./checkpoints", "Path to save checkpoints.") model_g.add_arg("config_path", str, "./data/input/model.conf", "Model conf.") model_g.add_arg("build_dict", bool, False, "Build dict.") train_g = ArgumentGroup(parser, "training", "training options.") train_g.add_arg("cpu_num", int, 3, "Number of Threads.") train_g.add_arg("epoch", int, 100, "Number of epoches for training.") train_g.add_arg("learning_rate", float, 0.1, "Learning rate used to train with warmup.") train_g.add_arg("save_steps", int, 1000, "The steps interval to save checkpoints.") train_g.add_arg("validation_steps", int, 100,
from nets import bilstm_net from nets import gru_net from nets import ernie_base_net from nets import ernie_bilstm_net from preprocess.ernie import task_reader from models.representation.ernie import ErnieConfig from models.representation.ernie import ernie_encoder, ernie_encoder_with_paddle_hub from models.representation.ernie import ernie_pyreader from models.model_check import check_cuda from utils import ArgumentGroup from utils import print_arguments from utils import init_checkpoint # yapf: disable parser = argparse.ArgumentParser(__doc__) model_g = ArgumentGroup(parser, "model", "model configuration and paths.") model_g.add_arg("ernie_config_path", str, None, "Path to the json file for ernie model config.") model_g.add_arg("senta_config_path", str, None, "Path to the json file for senta model config.") model_g.add_arg("init_checkpoint", str, None, "Init checkpoint to resume training from.") model_g.add_arg("checkpoints", str, "checkpoints", "Path to save checkpoints") model_g.add_arg("model_type", str, "ernie_base", "Type of current ernie model") model_g.add_arg("use_paddle_hub", bool, False, "Whether to load ERNIE using PaddleHub") train_g = ArgumentGroup(parser, "training", "training options.") train_g.add_arg("epoch", int, 10, "Number of epoches for training.") train_g.add_arg("save_steps", int, 10000, "The steps interval to save checkpoints.") train_g.add_arg("validation_steps", int, 1000, "The steps interval to evaluate model performance.") train_g.add_arg("lr", float, 0.002, "The Learning rate value for training.") log_g = ArgumentGroup(parser, "logging", "logging related") log_g.add_arg("skip_steps", int, 10, "The steps interval to print loss.")
from nets import cnn_net from nets import bilstm_net from nets import gru_net from models.model_check import check_cuda import paddle import paddle.fluid as fluid import reader from config import SentaConfig from utils import ArgumentGroup, print_arguments from utils import init_checkpoint # yapf: disable parser = argparse.ArgumentParser(__doc__) model_g = ArgumentGroup(parser, "model", "model configuration and paths.") model_g.add_arg("senta_config_path", str, None, "Path to the json file for senta model config.") model_g.add_arg("init_checkpoint", str, None, "Init checkpoint to resume training from.") model_g.add_arg("checkpoints", str, "checkpoints", "Path to save checkpoints") train_g = ArgumentGroup(parser, "training", "training options.") train_g.add_arg("epoch", int, 10, "Number of epoches for training.") train_g.add_arg("save_steps", int, 10000, "The steps interval to save checkpoints.") train_g.add_arg("validation_steps", int, 1000, "The steps interval to evaluate model performance.") train_g.add_arg("lr", float, 0.002, "The Learning rate value for training.") log_g = ArgumentGroup(parser, "logging", "logging related") log_g.add_arg("skip_steps", int, 10, "The steps interval to print loss.") log_g.add_arg("verbose", bool, False, "Whether to output verbose log") data_g = ArgumentGroup(parser, "data", "Data paths, vocab paths and data processing options")