Пример #1
0
Файл: all.py Проект: frsong/pyrl
#=========================================================================================

here   = utils.get_here(__file__)
parent = utils.get_parent(here)

dopath        = join(parent, 'examples')
modelspath    = join(parent, 'examples', 'models')
analysispath  = join(parent, 'examples', 'analysis')
paperpath     = join(parent, 'paper')
timespath     = join(paperpath, 'times')
paperdatapath = join(paperpath, 'work', 'data')
paperfigspath = join(paperpath, 'work', 'figs')

# Make paths
for path in [timespath, paperdatapath, paperfigspath]:
    utils.mkdir_p(path)

def call(s):
    if simulate:
        print(3*' ' + s)
    else:
        rval = subprocess.call(s.split())
        if rval != 0:
            sys.stdout.flush()
            print("Something went wrong (return code {}).".format(rval))
            sys.exit(1)

def train(model, seed=None, main=False):
    if seed is None:
        extra = ''
    else:
Пример #2
0
name = os.path.splitext(os.path.basename(modelfile))[0] + suffix

# Scratch
scratchpath = os.environ.get('SCRATCH')
if scratchpath is None:
    scratchpath = os.path.join(os.environ['USERPROFILE'], 'scratch')
trialspath = os.path.join(scratchpath, 'work', 'pyrl', prefix, name)

# Paths
workpath = os.path.join(here, 'work')
datapath = os.path.join(workpath, 'data', name)
figspath = os.path.join(workpath, 'figs', name)

# Create necessary directories
for path in [datapath, figspath, trialspath]:
    utils.mkdir_p(path)

# File to store model in
savefile = os.path.join(datapath, name + '.pkl')

#=========================================================================================
# Info
#=========================================================================================

if action == 'info':
    # Model specification
    model = Model(modelfile)

    # Create a PolicyGradient instance
    pg = model.get_pg(savefile, seed)