Created
June 15, 2020 10:44
-
-
Save Steve-Tech/869d4304bc1b911a2fa9bef96928be00 to your computer and use it in GitHub Desktop.
A gpt_2_simple script for finishing a paragraph.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gpt_2_simple as gpt2 | |
choose_model = int(input("Choose Model 0 - 124M, 1 - 335M, 2 - 774M, 3 - 1158M: ")) | |
model_name = ["124M", "355M", "774M", "1558M"][choose_model] | |
if input("Download Model [y/N]: ").lower() == 'y': | |
gpt2.download_gpt2(model_name=model_name) | |
if input("Use CPU [y/N]: ").lower() == 'y': | |
from os import environ | |
environ['CUDA_VISIBLE_DEVICES'] = '-1' | |
prefix = input("Enter Prefix: ") | |
length = input("Enter Length [500]: ") | |
if not length: | |
length = 500 | |
temperature = input("Enter Temperature [0.7]: ") | |
if not temperature: | |
temperature = 0.7 | |
samples = input("Enter Sample Amount [1]: ") | |
if not samples: | |
samples = 1 | |
batch_size = input("Enter Batch Size [1]: ") | |
if not batch_size: | |
batch_size = 1 | |
sess = gpt2.start_tf_sess() | |
gpt2.load_gpt2(sess, model_name=model_name) | |
gpt2.generate(sess, | |
model_name=model_name, | |
prefix=prefix, | |
length=int(length), | |
temperature=float(temperature), | |
nsamples=int(samples), | |
batch_size=int(batch_size) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment