รหัสสำหรับการฝึกอบรมและการประเมินผลของแบบจำลองจาก "การสร้างภาษาที่มีเครือข่ายฝ่ายตรงข้ามที่เกิดขึ้นซ้ำ ๆ โดยไม่ต้องฝึกอบรมก่อน"
มีการสรุปสั้น ๆ ของกระดาษที่นี่
" There has been to be a place w
On Friday , the stories in Kapac
From should be taken to make it
He is conference for the first t
For a lost good talks to ever ti
ในการเริ่มต้นการฝึกอบรมรุ่น CL+VL+TH ให้ดาวน์โหลดชุดข้อมูลก่อนที่ http://www.statmt.org/lm-benchmark/ และแยกลงในไดเรกทอรี ./data
จากนั้นใช้คำสั่งต่อไปนี้:
python curriculum_training.py
จำเป็นต้องมีแพ็คเกจต่อไปนี้:
สามารถกำหนดค่าพารามิเตอร์ต่อไปนี้ได้:
LOGS_DIR: Path to save model checkpoints and samples during training (defaults to './logs/')
DATA_DIR: Path to load the data from (defaults to './data/1-billion-word-language-modeling-benchmark-r13output/')
CKPT_PATH: Path to checkpoint file when restoring a saved model
BATCH_SIZE: Size of batch (defaults to 64)
CRITIC_ITERS: Number of iterations for the discriminator (defaults to 10)
GEN_ITERS: Number of iterations for the geneartor (defaults to 50)
MAX_N_EXAMPLES: Number of samples to load from dataset (defaults to 10000000)
GENERATOR_MODEL: Name of generator model (currently only 'Generator_GRU_CL_VL_TH' is available)
DISCRIMINATOR_MODEL: Name of discriminator model (currently only 'Discriminator_GRU' is available)
PICKLE_PATH: Path to PKL directory to hold cached pickle files (defaults to './pkl')
ITERATIONS_PER_SEQ_LENGTH: Number of iterations to run per each sequence length in the curriculum training (defaults to 15000)
NOISE_STDEV: Standard deviation for the noise vector (defaults to 10.0)
DISC_STATE_SIZE: Discriminator GRU state size (defaults to 512)
GEN_STATE_SIZE: Genarator GRU state size (defaults to 512)
TRAIN_FROM_CKPT: Boolean, set to True to restore from checkpoint (defaults to False)
GEN_GRU_LAYERS: Number of GRU layers for the genarator (defaults to 1)
DISC_GRU_LAYERS: Number of GRU layers for the discriminator (defaults to 1)
START_SEQ: Sequence length to start the curriculum learning with (defaults to 1)
END_SEQ: Sequence length to end the curriculum learning with (defaults to 32)
SAVE_CHECKPOINTS_EVERY: Save checkpoint every # steps (defaults to 25000)
LIMIT_BATCH: Boolean that indicates whether to limit the batch size (defaults to true)
พารามิเตอร์สามารถตั้งค่าได้โดยการเปลี่ยนค่าของพวกเขาในไฟล์ config หรือผ่านไปในเทอร์มินัล:
python curriculum_training.py --START_SEQ=1 --END_SEQ=32
สคริปต์ generate.py จะสร้างตัวอย่าง BATCH_SIZE โดยใช้โมเดลที่บันทึกไว้ ควรเรียกใช้โดยใช้พารามิเตอร์ที่ใช้ในการฝึกอบรมโมเดล (หากแตกต่างจากค่าเริ่มต้น) ตัวอย่างเช่น:
python generate.py --CKPT_PATH=/path/to/checkpoint/seq-32/ckp --DISC_GRU_LAYERS=2 --GEN_GRU_LAYERS=2
(หากแบบจำลองของคุณยังไม่ถึงขั้นตอนที่ 32 ในหลักสูตรตรวจสอบให้แน่ใจว่าได้เปลี่ยน '32' ในเส้นทางด้านบนเป็นขั้นตอนสูงสุดในหลักสูตรที่โมเดลของคุณได้รับการฝึกฝน)
ในการประเมินตัวอย่างโดยใช้ตัวชี้วัด %-in-test-N-N ให้ใช้คำสั่งต่อไปนี้เชื่อมโยงไปยังไฟล์ txt ที่แต่ละแถวเป็นตัวอย่าง:
python evaluate.py --INPUT_SAMPLE=/path/to/samples.txt
หากคุณพบรหัสนี้มีประโยชน์โปรดอ้างอิงกระดาษต่อไปนี้:
@article{press2017language,
title={Language Generation with Recurrent Generative Adversarial Networks without Pre-training},
author={Press, Ofir and Bar, Amir and Bogin, Ben and Berant, Jonathan and Wolf, Lior},
journal={arXiv preprint arXiv:1706.01399},
year={2017}
}
ที่เก็บนี้ขึ้นอยู่กับรหัสที่เผยแพร่ในการฝึกอบรมที่ดีขึ้นของ Wasserstein Gans