Esempio n. 1
0
def runTester(testWeightsQueue, resultQueue, abort):
    try:
        env = getEnv()
        env.reset()

        tester = Tester(env)
        tester.build()

        while not abort.value:
            weights = testWeightsQueue.get()
            tester.model.set_weights(weights)
            log = tester.runOneEpisode(abort)
            resultQueue.put(log)
    except KeyboardInterrupt:
        pass
Esempio n. 2
0
def runExplorer(ID, weightsQueue, expQueue, abort, weightNoiseProb=0.):
    try:
        env = getEnv()
        env.reset()
        nc = noiseConfig[ID % len(noiseConfig)]
        noise = getNoise(nc, env.action_space.shape[0])

        exp = Explorer(ID=ID,
                       env=env,
                       weightNoiseProb=weightNoiseProb,
                       noiseProcess=noise)
        exp.build()

        while not abort.value:
            weights = weightsQueue.get()
            exp.model.set_weights(weights)
            results = exp.runOneEpisode(abort)
            expQueue.put(results)
    except KeyboardInterrupt:
        pass
Esempio n. 3
0
parser.add_argument('--interval',
                    dest='interval',
                    action='store',
                    default=100,
                    type=int)  #checkpoint interval
parser.add_argument('--obs', dest='obs', action='store_true', default=False)
parser.add_argument('--vis',
                    dest='visualize',
                    action='store_true',
                    default=False)
args = parser.parse_args()

from source.agents.testActor import TestActor
from config import getActor, getEnv, ENV_TAG

env = getEnv(visualize=args.visualize)
env.reset()

if args.visualize:
    if ENV_TAG == 'OSIM':
        vis = env.osim_model.model.updVisualizer().updSimbodyVisualizer()
        vis.setBackgroundType(vis.GroundAndSky)

actor = getActor(env)
print(actor.summary())

tester = TestActor(actor)
epoch = args.start
log = []
while True:
    try:
Esempio n. 4
0
    wQueues.append(weightsQueue)

from source.agents.tester import runTester
p = Process(target=runTester, args=(
    testWeights,
    testResults,
    abort,
))
p.daemon = True
p.start()

#### Initiate main process agent for training ####

from source.customKerasLayers import LayerNormDense
from source.agents.customDDPG import CollectiveDDPG
env = getEnv()
env.reset()
numActions = env.action_space.shape[0]
memory_ = memory
optimizer_ = optimizer

actor, critic, metrics_, action_input = getActorCritic(env)

print(actor.summary())
print(critic.summary())

agent = CollectiveDDPG(weightNoiseProb=wnprob,
                       nb_actions=numActions,
                       actor=actor,
                       critic=critic,
                       critic_action_input=action_input,