/usr/local/lib/python3.6/site-packages/transformers/commands/__pycache__
NameSizeModeActions
add_new_model.cpython-36.pyc65310644editdlrm
add_new_model_like.cpython-36.pyc426880644editdlrm
convert.cpython-36.pyc49430644editdlrm
download.cpython-36.pyc16600644editdlrm
env.cpython-36.pyc26050644editdlrm
lfs.cpython-36.pyc72440644editdlrm
run.cpython-36.pyc33720644editdlrm
serving.cpython-36.pyc67480644editdlrm
train.cpython-36.pyc45890644editdlrm
transformers_cli.cpython-36.pyc12610644editdlrm
user.cpython-36.pyc84530644editdlrm
__init__.cpython-36.pyc7940644editdlrm
Edit: /usr/local/lib/python3.6/site-packages/transformers/commands/__pycache__/train.cpython-36.pyc (4589B)
3 Eg@sddlZddlmZmZddlmZddlmZddl m Z m Z m Z ddl mZe rhe rhed d Zd Zed d d ZGdddeZdS)N)ArgumentParser Namespace)%SingleSentenceClassificationProcessor)TextClassificationPipeline)is_tf_availableis_torch_availablelogging)BaseTransformersCLICommandzRAt least one of PyTorch or TensorFlow 2.0+ should be installed to use CLI trainingF)argscCst|S)z Factory function used to instantiate training command from provided command line arguments. Returns: TrainCommand ) TrainCommand)r rE/usr/local/lib/python3.6/site-packages/transformers/commands/train.pytrain_command_factory src@sDeZdZeedddZedddZddZd d Z d d Z d S)r )parsercCs|jddd}|jdtddd|jdtd d d |jd td dd |jdtddd |jdddd|jdtddd |jdtddd |jdtddd |jdtd d!d |jd"td#d$d |jd%td&d'd |jd(td)d*d |jd+td,d-d |jd.td/d0d |jtd1d2S)3z Register this command to argparse so it's available for the transformer-cli Args: parser: Root parser to register command-specific arguments Ztrainz$CLI tool to train a model on a task.)helpz --train_dataTzcpath to train (and optionally evaluation) dataset as a csv with tab separated labels and sentences.)typerequiredrz--column_labelrz3Column of the dataset csv file with example labels.)rdefaultrz --column_textr z2Column of the dataset csv file with example texts.z --column_idrz0Column of the dataset csv file with example ids.z--skip_first_row store_truez-Skip the first row of the csv file (headers).)actionrz--validation_datazpath to validation dataset.z--validation_splitg?z^if validation dataset is not provided, fraction of train dataset to use as validation dataset.z--outputz./z path to saved the trained model.z--tasktext_classificationzTask to train the model on.z--modelzbert-base-uncasedz%Model's name or path to stored model.z--train_batch_size zBatch size for training.z--valid_batch_size@zBatch size for validation.z--learning_rategiUMu>zLearning rate.z--adam_epsilong:0yE>zEpsilon for Adam optimizer.)funcN) add_parser add_argumentstrintfloat set_defaultsr)rZ train_parserrrrregister_subcommand*s< z TrainCommand.register_subcommand)r cCsBtjd|_trdnd|_tj|jdd|j|_|j|_|j |_ |j |_ |jj d|j d|j |j dkrtj|j |_n|j d krtn|j d krt|jj d |jtj|j|j|j |j |jd |_d|_|jr|jj d |jtj|j|j|j |j |jd |_|j|_|j|_|j|_|j|_|j|_dS)Nztransformers-cli/trainingtfZtorchT)exist_okzLoading z pipeline for rZtoken_classificationZquestion_answeringzLoading dataset from ) column_label column_text column_idskip_first_rowz Loading validation dataset from )r get_loggerloggerr frameworkosmakedirsoutputr&r'r(infotaskmodelrZfrom_pretrainedpipelineNotImplementedErrorZ train_data ProcessorZcreate_from_csvr) train_dataset valid_datasetvalidation_datavalidation_splittrain_batch_sizevalid_batch_size learning_rate adam_epsilon)selfr rrr__init__^sF      zTrainCommand.__init__cCs|jdkr|jS|jS)Nr$)r,run_tf run_torch)r>rrrruns zTrainCommand.runcCstdS)N)r4)r>rrrrAszTrainCommand.run_torchc Cs:|jj|j|j|j|j|j|j|jd|jj |j dS)N)r8r9r<r=r:r;) r3Zfitr6r7r9r<r=r:r;Zsave_pretrainedr/)r>rrrr@s zTrainCommand.run_tfN) __name__ __module__ __qualname__ staticmethodrr#rr?rBrAr@rrrrr )s 3-r )r-argparserrdatarr5Z pipelinesrutilsrrr rr RuntimeErrorZUSE_XLAZUSE_AMPrr rrrrs