Exemple #1
0
        for i_step in range(args.max_episode_step):
            env.render()
            a, log_prob = agent.choose_action(obs)
            obs_, r_e, done, _ = env.step(a)
            mask = 0 if done else 1
            r_i = agent.compute_intrinsic_reward(obs_)
            agent.buffer.store(obs, a, r_i, r_e, mask, obs_, log_prob)

            if total_step % args.rollout_len == 0 and total_step > 0:
                loss_RND, loss_actor, loss_critic = agent.update()
                logger.add_scalar('loss/loss_RND', loss_RND, total_step)
                logger.add_scalar('loss/loss_actor', loss_actor, total_step)
                logger.add_scalar('loss/loss_critic', loss_critic, total_step)

            obs = obs_
            total_step += 1
            episode_reward += r_e
            if done:
                break
            
        print('episode: {}  total step: {}  episode reward: {}'.format(i_episode, total_step, episode_reward))
        logger.add_scalar('Indicator/episode_reward', episode_reward, i_episode)

        if i_episode > args.max_episode * 2/3 and i_episode % args.save_model_interval == 0:
            agent.save_model(remark='episode_{}'.format(i_episode))
'''

if __name__ == '__main__':
    args = add_arguments()
    paralle_train(args)
Exemple #2
0
            referenceFile + " and " + inFile + " in " + str(diffTime) +
            " seconds")
        rsltText = "-;-;-;-;timeout"
        save_results(outFile, rsltText)
        return

    endTime = time.time()
    diffTime = int(endTime - startTime)
    print(
        str(count) + "/" + str(totalCount) + " SUCCESS: - Comparing " +
        referenceFile + " and " + inFile + " in " + str(diffTime) + " seconds")


if __name__ == "__main__":
    parser = parser.CommonParser()
    parser.add_arguments(['--input', '--reference'])

    arguments = parser.check_values()

    listFiles = []
    for fileName in os.listdir(arguments.input):
        extension = os.path.splitext(fileName)[1][1:]
        if extension == 'pdf':
            fileNamePath = os.path.join(arguments.input, fileName)
            fileNameWithoutPDF = os.path.splitext(fileName)[0]
            referencePath = os.path.join(
                arguments.reference,
                os.path.splitext(fileNameWithoutPDF)[0] + ".pdf")
            if os.path.exists(referencePath):
                outFile = fileNamePath + '-pair.pdf'
                if not os.path.exists(outFile):
                str(count) + "/" + str(total_count) +
                " - TIMEOUT: Converting " + inputName + " to " + outputName +
                ' after ' + str(diffTime) + ' seconds')
        else:
            # Some files are corrupted
            print(
                str(count) + "/" + str(total_count) + " - ERROR: Converting " +
                inputName + " to " + outputName + ' after ' + str(diffTime) +
                ' seconds')

    os.remove(os.path.join('/tmp', fileName))


if __name__ == "__main__":
    parser = parser.CommonParser()
    parser.add_arguments(
        ['--input', '--output', '--extension', '--wineprefix'])

    arguments = parser.check_values()

    if not display_in_used():
        print("Display :0 is no in used. Emulating it ")
        Popen(["Xvfb", ":0", "-screen", "0", "1024x768x16"])

    if "DISPLAY" not in os.environ:
        os.environ["DISPLAY"] = ":0.0"
    os.environ["WINEPREFIX"] = arguments.wineprefix

    listFiles = []

    for fileName in os.listdir(arguments.input):
        if fileName.endswith('.' + arguments.extension):
                                  str(count) + '/' + str(total_count))))
            runConnectionTests(connection, simpleInvoke, tests)

            exportedFiles = [
                item for sublist in tests for item in sublist.exportedFiles
            ]

        finally:
            connection.kill()

        return exportedFiles


if __name__ == "__main__":
    parser = parser.CommonParser()
    parser.add_arguments(
        ['--soffice', '--type', '--component', '--input', '--output'])

    arguments = parser.check_values()

    extensions = config.config[arguments.type][arguments.component]["import"]
    importFiles = getFiles(arguments.input, extensions)

    if importFiles:
        exportedFiles = runLoadFileTests(arguments, importFiles, True)
    else:
        print("unoconv.py: Nothing to be converted")
        sys.exit(2)

    if exportedFiles:
        # Convert the roundtripped odf files to PDF
        runLoadFileTests(arguments, exportedFiles, False)