示例#1
0
#!/usr/bin/env python3
#
# Reverse : Generate an indented asm code (pseudo-C) with colored syntax.
# Copyright (C) 2015    Joel
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.    See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.    If not, see <http://www.gnu.org/licenses/>.
#

from lib import reverse, parse_args

if __name__ == '__main__':
    ctx = parse_args()

    if ctx.interactive:
        from lib.interactive import Interactive
        i = Interactive(ctx)
    elif ctx.filename is not None:
        reverse(ctx)
示例#2
0
import torch.optim as optim
import torch.nn.functional as F

GAMMA = 0.99
BATCH_SIZE = 64
LR_ACTS = 1e-4
LR_VALS = 1e-4
REPLAY_SIZE = 100000
REPLAY_INITIAL = 10000
SAC_ENTROPY_ALPHA = 0.1

if __name__ == "__main__":

    parser = make_parser(test_iters=10000)

    args, device, save_path, test_env, maxeps, maxsec = parse_args(
        parser, "sac")

    env = make_env(args)

    net_act, net_crt = make_nets(args, env, device)

    twinq_net = model.ModelSACTwinQ(env.observation_space.shape[0],
                                    env.action_space.shape[0]).to(device)
    print(twinq_net)

    tgt_net_crt = ptan.agent.TargetNet(net_crt)

    writer = SummaryWriter(comment="-sac_" + args.name)
    agent = model.AgentDDPG(net_act, device=device)
    exp_source = ptan.experience.ExperienceSourceFirstLast(env,
                                                           agent,
示例#3
0

#possible argv
c = ['--corpora']
m = ['--mini']
v = ['--vectorize']
s = ['--svm', '--classify']
p = ['--parse']
a = ['--all']
d = ['--delete', '--clean']

#get argv
argv = sys.argv[1:]
if not len(argv):  #make --all the default option
    argv += a
if not parse_args(argv, c + m + v + s + p + a + d):  #invalid option
    print('Please select a valid option.')

#exec scripts
if parse_args(argv, c + a):
    from scripts import format_bnc, format_wiki
if parse_args(argv, m + a):
    from scripts import mini_corpora
if parse_args(argv, v + a):
    from scripts import vectorize
if parse_args(argv, s + a):
    os.makedirs(Svm.svmdir, exist_ok=True)
    os.system('python3 -u scripts/classify.py > ' + \
     f'{Svm.svmdir}{Svm.desc}.txt')
if parse_args(argv, p + a):
    from scripts import parse
    file_name = Path.joinpath(DIR_PROJECT_FOLDER, "nodemon.json")
    create_from_template("cpy_nodemon_json", file_name, {"project": project})

    create_empty_files(DIR_PROJECT_MAIN, ['__init__.py'])

    if pip:
        print("Init pip environment")
        os.system("pipenv install autopep8 pyinstaller ptpython --dev")
        os.system("pipenv install requests python-dotenv")

        if args.flaskapp:
            install_flask_app_dependencies()

        if args.packages:
            os.system('pipenv install ' + args.packages)

    add_git(project)

    if open_vs_code:
        os.chdir(DIR_PROJECT_FOLDER)
        os.system(f"code . {main_file_name}")

    if pip:
        os.system(f"pipenv shell")


if __name__ == "__main__":
    args = parse_args()
    run(pip=args.pipenv)
    os.chdir(DIR_PROJECT_PUBLIC_FOLDER)
    crap.handle_index_html(DIR_PROJECT_PUBLIC_FOLDER, project_name)

    os.chdir(DIR_PROJECT_SRC_FOLDER)
    crap.remove_files()
    crap.create_app_jsx(DIR_PROJECT_SRC_FOLDER, project_name)
    crap.create_index_css(DIR_PROJECT_SRC_FOLDER)
    create_empty_files(DIR_PROJECT_SRC_FOLDER, ['App.css'])

    os.chdir(DIR_PROJECT_FOLDER)
    crap.handle_readme_file(DIR_PROJECT_FOLDER, project_name)
    create_empty_files(DIR_PROJECT_FOLDER, ['.env'])

    if packages:
        os.system('yarn add ' + packages)

    # Handle GIT
    os.system('echo ".env" >> .gitignore')
    os.system('git add .')
    os.system('git commit -m "removed crap files to empty project" ')

    os.system('code .')
    os.system('yarn start')



if __name__ == "__main__":
    run(parse_args())