Dataset Viewer
Auto-converted to Parquet Duplicate
python_code
stringlengths
0
869k
from setuptools import setup, find_packages setup( name='coinrun', packages=find_packages(), version='0.0.1', )
import numpy as np from coinrun import setup_utils, make def random_agent(num_envs=1, max_steps=100000): setup_utils.setup_and_load(use_cmd_line_args=False) env = make('standard', num_envs=num_envs) for step in range(max_steps): acts = np.array([env.action_space.sample() for _ in range(env.num_env...
""" Load an agent trained with train_agent.py and """ import time import tensorflow as tf import numpy as np from coinrun import setup_utils import coinrun.main_utils as utils from coinrun.config import Config from coinrun import policies, wrappers mpi_print = utils.mpi_print def create_act_model(sess, env, nenvs)...
""" Train an agent using a PPO2 based on OpenAI Baselines. """ import time from mpi4py import MPI import tensorflow as tf from baselines.common import set_global_seeds import coinrun.main_utils as utils from coinrun import setup_utils, policies, wrappers, ppo2 from coinrun.config import Config def main(): args = ...
from mpi4py import MPI import argparse import os class ConfigSingle(object): """ A global config object that can be initialized from command line arguments or keyword arguments. """ def __init__(self): self.WORKDIR = './saved_models/' self.TB_DIR = '/tmp/tensorflow' if not o...
""" This is a copy of PPO from openai/baselines (https://github.com/openai/baselines/blob/52255beda5f5c8760b0ae1f676aa656bb1a61f80/baselines/ppo2/ppo2.py) with some minor changes. """ import time import joblib import numpy as np import tensorflow as tf from collections import deque from mpi4py import MPI from coinru...
import tensorflow as tf from mpi4py import MPI from coinrun.config import Config import numpy as np def clean_tb_dir(): comm = MPI.COMM_WORLD rank = comm.Get_rank() if rank == 0: if tf.gfile.Exists(Config.TB_DIR): tf.gfile.DeleteRecursively(Config.TB_DIR) tf.gfile.MakeDirs(Con...
from .coinrunenv import init_args_and_threads from .coinrunenv import make __all__ = [ 'init_args_and_threads', 'make' ]
import gym import numpy as np class EpsilonGreedyWrapper(gym.Wrapper): """ Wrapper to perform a random action each step instead of the requested action, with the provided probability. """ def __init__(self, env, prob=0.05): gym.Wrapper.__init__(self, env) self.prob = prob s...
""" Run a CoinRun environment in a window where you can interact with it using the keyboard """ from coinrun.coinrunenv import lib from coinrun import setup_utils def main(): setup_utils.setup_and_load(paint_vel_info=0) print("""Control with arrow keys, F1, F2 -- switch resolution, F5, F6, F7, F8 -- zoom, F9...
import tensorflow as tf import os import joblib import numpy as np from mpi4py import MPI from baselines.common.vec_env.vec_frame_stack import VecFrameStack from coinrun.config import Config from coinrun import setup_utils, wrappers import platform def make_general_env(num_env, seed=0, use_sub_proc=True): from ...
from coinrun.config import Config import os import joblib def load_for_setup_if_necessary(): restore_file(Config.RESTORE_ID) def restore_file(restore_id, load_key='default'): if restore_id is not None: load_file = Config.get_load_filename(restore_id=restore_id) filepath = file_to_path(load_fi...
from coinrun import random_agent def test_coinrun(): random_agent.random_agent(num_envs=16, max_steps=100) if __name__ == '__main__': test_coinrun()
import numpy as np import tensorflow as tf from baselines.a2c.utils import conv, fc, conv_to_fc, batch_to_seq, seq_to_batch, lstm from baselines.common.distributions import make_pdtype from baselines.common.input import observation_input from coinrun.config import Config def impala_cnn(images, depths=[16, 32, 32]): ...
""" Python interface to the CoinRun shared library using ctypes. On import, this will attempt to build the shared library. """ import os import atexit import random import sys from ctypes import c_int, c_char_p, c_float, c_bool import gym import gym.spaces import numpy as np import numpy.ctypeslib as npct from basel...
import json import pickle import math import sys import argparse import warnings from os import makedirs from os.path import basename, join, exists, dirname, splitext, realpath from wikidata_linker_utils.progressbar import get_progress_bar from dataset import TSVDataset, CombinedDataset, H5Dataset, ClassificationHand...
import numpy as np import subprocess import h5py import ciseau from os.path import exists, splitext, join from wikidata_linker_utils.wikidata_ids import load_wikidata_ids def count_examples(lines, comment, ignore_value, column_indices): example_length = 0 has_labels = False found = 0 for line in lines:...
import queue import threading def prefetch_generator(generator, to_fetch=10): q = queue.Queue(maxsize=to_fetch) def thread_worker(queue, gen): for val in gen: queue.put(val) queue.put(None) t = threading.Thread(target=thread_worker, args=(q, generator)) some_exception = N...
End of preview. Expand in Data Studio
README.md exists but content is empty.
Downloads last month
10

Models trained or fine-tuned on kye/all-openai-github-code