コード例 #1
0
ファイル: main.py プロジェクト: lbwwslove/coursera
def run_image(image_path):
    print(image_path)

    image = mpimg.imread(image_path)
    runner = Runner(image.shape)
    runner.run(image)

    plt.figure()
    plt.imshow(image)
    plt.show()
コード例 #2
0
ファイル: main.py プロジェクト: xtanitfy/LaneATT
def main():
    args = parse_args()
    exp = Experiment(args.exp_name, args, mode=args.mode)
    if args.cfg is None:
        cfg_path = exp.cfg_path
    else:
        cfg_path = args.cfg
    cfg = Config(cfg_path)
    exp.set_cfg(cfg, override=False)
    device = torch.device('cpu') if not torch.cuda.is_available() or args.cpu else torch.device('cuda')
    runner = Runner(cfg, exp, device, view=args.view, resume=args.resume, deterministic=args.deterministic)
    if args.mode == 'train':
        try:
            runner.train()
        except KeyboardInterrupt:
            logging.info('Training interrupted.')
    runner.eval(epoch=args.epoch or exp.get_last_checkpoint_epoch(), save_predictions=args.save_predictions)
コード例 #3
0
def main() -> None:
    args = parse_args()
    exp = Experiment(args.exp_name, args, mode=args.mode)
    if args.cfg is None:
        cfg_path = exp.cfg_path
    else:
        cfg_path = args.cfg
    cfg = Config(cfg_path)
    exp.set_cfg(cfg, override=False)
    device = (
        torch.device("cpu") if not torch.cuda.is_available() else torch.device("cuda")
    )
    runner = Runner(cfg, exp, device, resume=args.resume)
    if args.mode == "train":
        try:
            runner.train()
        except KeyboardInterrupt:
            logging.info("Training interrupted.")
コード例 #4
0
ファイル: judger.py プロジェクト: bianyuanop/SWJTU_OJ_EXAM
    def run(self):
        # TODO: add loop here to check taskQueue
        while True:
            try:
                if not self.runnerQueue.empty():
                    runner = self.runnerQueue.get()
                    if not runner.is_alive():
                        running_result = runner.getResult()
                        err_code = running_result['err_code']
                        retval = running_result['retval']
                        errmess = running_result['errmess']

                        toPut = {"runningResult": running_result, "score": 0}

                        if err_code:
                            toPut['score'] = 0
                        else:
                            # use similiar rate to judge for two equal one it will compute 100
                            print(self.rightAnswerDict[runner.getJudgeId()])
                            toPut['score'] = self._similiar(
                                retval, self.rightAnswerDict[
                                    runner.getJudgeId()]) * 100

                        print("TOPUT: ", toPut)
                        self.doneQueue.put(toPut)
                    else:
                        self.runnerQueue.put(runner)
                        print("put back")

                if not self.taskQueue.empty():
                    toJudge = self.taskQueue.get()
                    runner = Runner(toJudge['lang'],
                                    toJudge['code'],
                                    toJudge['input'],
                                    subId=toJudge['judge_id'])
                    runner.start()
                    self.runnerQueue.put(runner)
            except Exception as e:
                print(e)
コード例 #5
0
ファイル: example.py プロジェクト: FergusInLondon/Runner
        the previous 5 2000ms updates. 
    """
    def start(self, control):
        self.series = pd.DataFrame()
        self.control = control

    def process(self, kline):
        self.series = self.series.append(kline)

        if self.series.shape[0] > 5:
            print("Average price change over past 5 windows: ",
                  pd.to_numeric(self.series[-5:]["PriceChange"]).mean())


if __name__ == "__main__":
    # Example Usage:
    #
    # Instantiate a `Runner`; providing API credentials, the symbol you wish to
    # run your strategy against, and the actual strategy itself. Then simply call
    # `.run()` to execute the strategy.

    cfg = configparser.ConfigParser()
    cfg.read('bot.ini')

    strategy = ExampleStrategy()
    runner = Runner(apiKey=cfg['credentials']['ApiKey'],
                    apiSecret=cfg['credentials']['ApiSecret'],
                    symbol=cfg['strategy']['Symbol'],
                    runnable=strategy)
    runner.run()
コード例 #6
0
    try:
        if hasattr(
                pymongo, 'version_tuple'
        ) and pymongo.version_tuple[0] >= 2 and pymongo.version_tuple[1] >= 4:
            from pymongo import MongoClient
            from pymongo.read_preferences import ReadPreference
            connection = MongoClient(host=options.server,
                                     read_preference=ReadPreference.SECONDARY)
        else:
            from pymongo.connection import Connection
            connection = Connection(options.server, slave_okay=True)
    except AutoReconnect, ex:
        print 'Connection to %s failed: %s' % (options.server, str(ex))
        return -1

    runner = Runner(connection, options.delay)

    rc = runner.run()

    if rc == -3:
        print 'Screen size too small'

    return rc


if __name__ == '__main__':
    sys.exit(main())

########NEW FILE########
コード例 #7
0
from lib.runner import Runner

Runner()
コード例 #8
0
                      tau_dm=args.tau_dm,
                      target_mode=args.target_mode)

## model
echo_dict = dict(tau=args.tau,
                 dt=1,
                 scale=args.rho_scale,
                 spars_echo=0.1,
                 scale_echo=args.scale_echo,
                 spars_p=0.1,
                 init_mode="mode_a")

model = Echo1(inp_size, args.n_echo, args.num_dm, echo_dict, dm_dict=dm_dict)

optimizer = optim.Adam(model.parameters(), lr=args.lr)
runner = Runner(model, optimizer)

#
"""
search the optimal parameters.

tau: runner.model.simple_echo.alpha = 1/tau
rho: runner.model.simple_echo.scale = rho

tau [tau_begin,tau_end,tau_step]
rho [rho_begin,rho_end,rho_step]
"""

rho_params = np.arange(args.rho_begin, args.rho_end, args.rho_step).tolist()
tau_params = np.arange(args.tau_begin, args.tau_end, args.tau_step).tolist()
tau_dm_params = np.arange(args.tau_dm_begin, args.tau_dm_end,
コード例 #9
0
from lib.classifier import NaiveBayes, SVM
from lib.runner import Runner
import numpy as np

runner = Runner(verbose = False)
f=open('data\params\\rbf\paraC.txt', 'w')
accuracies = []
j=0
for gamma in [2**i for i in range(-6,6,1)]:
    f.write('gamma=' + str(gamma) + ': \n a=[')
    for C in np.linspace(0, 1,101):
        if C!=0:
            j+=1
            svm = SVM(kernel='rbf', C=C, gamma=gamma)
            accuracy, testAccuracy=runner.run(svm)
            accuracies.append((accuracy, testAccuracy, C, gamma))
            f.write(str(C) + '   ' + str(accuracy) +';')#tu promjena kad se mijenja poredak petlji -> parametar najdublje petlje...
            print str((float(j) / (100*12)) * 100) + "%"
            print repr(accuracies[-1])
    f.write(']\n')
print repr(max(accuracies))
'''         accuracy = runner.run(svm)
f=open('data\params\linear\paraC.txt', 'w')
f.write('a=[')
accuracies = []
j=0
for C in np.linspace(0, 1,101):
    if C!=0:
        j=j+1
        svm = SVM(kernel='linear', C=C)
        accuracy, testAccuracy=runner.run(svm)
コード例 #10
0
ファイル: main.py プロジェクト: EXXETA/k8s-python-tools
def main():
    runner = Runner()
    runner.handle_args()
    runner.handle_invalid_input()
    runner.execute()
コード例 #11
0
ファイル: main.py プロジェクト: lbwwslove/coursera
 def run(self, image):
     if self.runner is None:
         self.runner = Runner(image.shape)
     return self.runner.run(image)
コード例 #12
0
from lib.classifier import NaiveBayes, SVM
from lib.runner import Runner

runner = Runner()

runner.run(
    NaiveBayes(),
    "Naive Bayes"
)

runner.run(
    SVM(kernel='rbf', C=0.91, gamma=0.03125),
    "SVM (RBF)"
)

runner.run(
    SVM(kernel='linear', C=0.05),
    "SVM (Linear)"
)

runner.run(
    SVM(kernel='poly', C=0.7, degree=2, gamma=0.25),
    "SVM (Polynomial)"
)