def loadgame(board, variations): root = Tk() root.filename = filedialog.askopenfilename( title="Select file", filetypes=(("hntf or txt files", "*.hntf"), ("tafl or txt files", "*.txt"), ("all files", "*.*"))) path = root.filename extension = '' if len(path) >= 4: for i in range(1, 5): extension += path[-i] if extension == 'txt.': try: tselection, tboard, ti_reader, tvariations = initialize() tvariations = convertfile(path) selection, board, i_reader, variations = tselection, tboard, ti_reader, tvariations except: pass if extension == 'ftnh': try: tselection, tboard, ti_reader, tvariations = initialize() tvariations = opentaflfile(path) selection, board, i_reader, variations = tselection, tboard, ti_reader, tvariations except: pass root.destroy() return board, variations
def main(): init.initialize() if FLAGS.train: train() if FLAGS.test: test() if FLAGS.export_file: export()
def main(): init.initialize() if FLAGS.train: train() elif FLAGS.predict: predict() elif FLAGS.export_file: export()
def main(): print('Starting', flush=True) init.initialize() if FLAGS.train: train() if FLAGS.test: test() if FLAGS.export_file: export()
def main(): parser = argparse.ArgumentParser() parser.add_argument( 'directory', help='Path to the repository. Example usage: run.sh path/to/directory') parser.add_argument( '--output', default='./repo_data.json', dest='output', help='Path to the JSON file that will contain the result') parser.add_argument( '--skip_obfuscation', default=False, dest='skip_obfuscation', action='store_true', help= 'If true it won\'t obfuscate the sensitive data such as emails and file names. Mostly for testing purpuse' ) parser.add_argument('--parse_libraries', default=True, action='store_true', dest='parse_libraries', help='If true, used libraries will be parsed') parser.add_argument( '--email', default='', dest='email', help='If set, commits from this email are preselected on authors list') parser.add_argument('--skip_upload', default=False, action='store_true', dest='skip_upload', help="If true, don't prompt for inmediate upload") try: args = parser.parse_args() folders = args.directory.split('|,|') if len(folders) > 1: q = Questions() repos = q.ask_which_repos(folders) if 'chosen_repos' not in repos or len(repos['chosen_repos']) == 0: print("No repos chosen, will exit") for repo in repos['chosen_repos']: repo_name = os.path.basename(repo).replace(' ', '_') output = ('./%s.json' % (repo_name)) initialize(repo, args.skip_obfuscation, output, args.parse_libraries, args.email, args.skip_upload) print('Finished analyzing %s ' % (repo_name)) else: initialize(args.directory, args.skip_obfuscation, args.output, args.parse_libraries, args.email, args.skip_upload) except KeyboardInterrupt: print("Cancelled by user") os._exit(0)
def initialize(self, check_permission=None): from init import initialize initialize() if self.is_wda: self.wda_client = wda.Client(self.wda_settings.get('url', None)) try: # quality: # 0-max(time is wasted to transfer large image), # 1-middle, # 2-lowest, may not clear enough # once changed the quality value, image templates should be updated print(f"window size = {self.wda_client.window_size()}") print(f"screenshot size = {self.wda_client.screenshot().size}") print(f"scale = {self.wda_client.scale}") print(f'WDA connected, current app: {config.wda_client.app_current()["bundleId"]}') default_settings = self.wda_client.appium_settings() settings = {k: v for k, v in self.wda_settings.items() if k in default_settings} if settings: print(f'set WDA: {settings}') print(self.wda_client.appium_settings(settings)) except Exception as e: print(f'Error:\n {e}') raise EnvironmentError(f'WebDriverAgent is not configured properly!') elif sys.platform == 'win32': # Android/iOS emulator in Windows # check admin permission & set process dpi awareness # please run cmd/powershell or Pycharm as administrator. if ctypes.windll.shell32.IsUserAnAdmin() == 0: if check_permission: print('[Emulator] Please run cmd/Pycharm as admin to click inside emulators with admin permission.') # To run a new process as admin, no effect in Pycharm's Python Console mode. # print('applying admin permission in a new process, and no effect when in console mode.') # ctypes.windll.shell32.ShellExecuteW(None, "runas", sys.executable, __file__, None, 1) raise PermissionError('Please run as administrator!') else: print('Running without admin permission.\n' 'Operations (e.g. click) within admin programs will take no effects!') else: # print('already admin') pass elif sys.platform == 'darwin': # Android emulator in macOS print('[Android Emulators] For the app who is running the script(PyCharm/Terminal/...), ' 'confirm these two permissions are granted:\n' ' "Accessibility" and "Screen Recording" inside "System Preferences/Security & Privacy/"\n', file=sys.stderr)
def main(): parser = argparse.ArgumentParser() parser.add_argument( 'directory', help='Path to the repository. Example usage: run.sh path/to/directory') parser.add_argument('--output', default='./repo_data.json', dest='output', help='Path to the JSON file that will contain the result. Use .json extension otherwise it cannot be recognized.') parser.add_argument('--skip_obfuscation', default=False, dest='skip_obfuscation', action='store_true', help='If true it won\'t obfuscate the sensitive data such as emails and file names. Mostly for testing purpose') parser.add_argument('--parse_libraries', default=True, action='store_true', dest='parse_libraries', help='If true, used libraries will be parsed') parser.add_argument('--email', default='', dest='email', help='If set, commits from this email are preselected on authors list') parser.add_argument('--skip_upload', default=False, action='store_true', dest='skip_upload', help="If true, don't prompt for inmediate upload") parser.add_argument('--debug_mode', default=False, action='store_true', dest='debug_mode', help="Print additional debug info into extractor_debug_info.log") parser.add_argument('--noskip', default=True, dest='skip', action='store_false', help='Do not skip any commits in analyze_libraries. May impact running time.') parser.add_argument('--commit_size_limit', default=5, type=int, help='If the estimated size of the changed files is bigger than this, we skip the commit') parser.add_argument('--file_size_limit', default=2, type=int, help='The library analyzer skips files bigger than this limit') try: args = parser.parse_args() folders=args.directory.split('|,|') if len(folders) > 1: q = Questions() repos = q.ask_which_repos(folders) if 'chosen_repos' not in repos or len(repos['chosen_repos']) == 0: print("No repos chosen, will exit") for repo in repos['chosen_repos']: repo_name = os.path.basename(repo).replace(' ','_') output=('./%s.json' % (repo_name)) initialize(repo, args.skip_obfuscation, output, args.parse_libraries, args.email, args.skip_upload, args.debug_mode, args.skip, args.commit_size_limit, args.file_size_limit) print('Finished analyzing %s ' % (repo_name)) else: initialize(args.directory, args.skip_obfuscation, args.output, args.parse_libraries, args.email, args.skip_upload, args.debug_mode, args.skip, args.commit_size_limit, args.file_size_limit) except KeyboardInterrupt: print("Cancelled by user") os._exit(0)
def __init__(self): super(BVM, self).__init__() self.pool = POOL self.conn = redis.Redis(connection_pool=self.pool) try: self.prices = initialize(self.pool) except Exception as e: print("ERROR 11: failed to initialize.")
def handler(): if len(sys.argv) > 1: # myDict init if sys.argv[1] == 'init': init.initialize() # myDict add elif sys.argv[1] == 'add' or sys.argv[1] == '-a': add.add() elif sys.argv[1] == 'show' or sys.argv[1] == '-s': # myDict show if len(sys.argv) == 2: show.showAllCategories() elif len(sys.argv) == 3: # myDict show all if sys.argv[2] == 'all': show.showAll() # myDict show <category> else: show.showItemsInCategory(sys.argv[2]) # myDict show <category> <name> elif len(sys.argv) == 4: show.showItem(sys.argv[2], sys.argv[3]) # myDicy help elif sys.argv[1] == 'help' or sys.argv[1] == '-h': help.help() # myDict find <item> elif sys.argv[1] == 'find' or sys.argv[1] == '-f': find.find(sys.argv[2]) # myDict export elif sys.argv[1] == 'export' or sys.argv[1] == '-e': if len(sys.argv) == 2: # myDict export all if sys.argv[2] == 'all': export.exportAll() # myDict export <category> else: export.exportSelectedItem()
def init_app(): """ create a new app, or sync with an existing one """ cwd = os.path.abspath('.') try: repo = git.Repo.discover(cwd) except NotGitRepository: click.echo("No repository found") sys.exit(1) suggested_name = init.get_default_name(cwd) if suggested_name is None: click.echo( "Unable to derive a name from the current git repository or directory!" ) sys.exit(2) name = click.prompt("Enter environment name".format(suggested_name), default=suggested_name) init.initialize(name, repo.head())
def gotovariation(ivar,variations,board): sequenceofmoves = [] count = 0 for i in range(ivar,0,-1): if variations[i][0]!='{' and variations[i][0]!='}' and count == 0: sequenceofmoves.append(variations[i]) if variations[i][0]=='}': count+=1 if variations[i][0]=='{' and count>0: count-=1 i-=1 selection, board, i, var = initialize() for i in range(len(sequenceofmoves)-1,-1,-1): board = playmove(board,sequenceofmoves[i][0],1,i,sequenceofmoves) return board
def main(): map_size = 100 p_type = 10 # dont get when we will use it max_route_length = 150 population_size = 30 number_of_each_new_generation = 10 number_of_couples = int( (population_size - number_of_each_new_generation) / 2) probability = 0.05 the_map = initialize(p_type, map_size) population = create_starting_population(max_route_length, population_size, the_map) last_distance = 1000000000 for i in range(0, 100): scores = score_population(population, the_map) new_population = [] best = population[np.argmin(scores)] number_of_moves = len(best) distance = fitness(best, the_map) if distance != last_distance: print( 'Iteration %i: Best so far is %i steps for a distance of %f' % (i, number_of_moves, distance)) plot_best(the_map, best, i) for j in range(0, number_of_couples): new_route1, new_route2 = crossover( population[pick_breeder(scores)], population[pick_breeder(scores)]) new_population.extend([new_route1, new_route2]) # mutate the current members of new_population for j in range(0, len(new_population)): new_population[j] = mutate(new_population[j], probability, the_map) new_population.append(population[np.argmin(scores)]) while len(new_population) < population_size: new_population.append(create_new_member(max_route_length, the_map)) population = new_population[::] # copy a values
def convertfile(data): alpha = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k'] f = open(data, "r") contents = f.read() res = [] write = False c = '' for e in contents: if (e == ' ' or e == '\n') and write: write = False res.append(c) c = '' if write: c += e if e == '\t': write = True if e == 'r': break selection, board, i_reader, variations = initialize() for e in res: c1 = alpha.index(e[0]) c = '' i = 1 while e[i] != '-': c += e[i] i += 1 i += 1 c2 = int(c) - 1 c3 = alpha.index(e[i]) i += 1 c = e[i] i += 1 if i <= len(e) - 1: if e[i] != 'x': c += e[i] c4 = int(c) - 1 selection, variations, i_reader = add_move( convert_coord_to_nb((c1, c2)), convert_coord_to_nb((c3, c4)), board, i_reader, variations) board = playmove(board, variations[i_reader][0], 1, i_reader, variations) return variations
from flask import Flask, request from flask_restful import Api import os import sys import configargparse from init import initialize from config import Config from apis import * app = Flask(__name__) api = Api(app) if __name__ == '__main__': config = initialize() # TODO: add api of authentication api.add_resource(Issue, '/api/issue') api.add_resource(Verify, '/api/verify/<string:id>', '/api/verify') api.add_resource(Revoke, '/api/revoke') api.add_resource(Cert, '/api/cert/<string:id>.json') api.add_resource(Certs, '/api/certs') api.add_resource(IssuerId, config.issuer_id_path) api.add_resource(RevocationList, config.revocation_list_path) app.run(debug=True)
from init import initialize initialize() from . import addon from . import autogui from . import base from . import config from . import dataset from . import gui from . import log from . import supervisor __all__ = [ 'addon', 'autogui', 'base', 'config', 'dataset', 'gui', 'log', 'supervisor', ]
from numpy import *; from average_green import averageGreen; from functions import *; from share_fun import *; # # INIT: for the details of variables, see return of init.py # # read input arguments parms, np, parms_file = getOptions(sys.argv[1:]); # create or open database (HDF5) h5file = h5py.File(parms['DATA_FILE'], 'a'); vars_dict = init.initialize(h5file, parms); for k, v in vars_dict.iteritems(): exec('%s=v'%k); # # DMFT, DMFT, DMFT !!! # set_printoptions(suppress=True, precision=4, linewidth=150); for k, v in parms.iteritems(): print k + " = " + str(v) + ";"; print "\n\n" parms['MEASURE'] = int(val_def(parms, 'MEASURE', -1)); if 'OBSERVABLES' in parms and parms['MEASURE'] < 0: parms['MEASURE'] = 0; if int(val_def(parms, 'ADJUST_DELTA_ONCE', 1)) > 0: Nd = -1; print "Only adjust double counting at the beginning"; it = h5["iter"][0];
import socket import time import random import threading from graph import Graph from init import initialize from helper import * topo_lock = threading.Lock() neighbors = [] topo = Graph() host, port = initialize(neighbors, topo) routing_table = [((host, port), ("0.0.0.0", 0), 0)] # (destination, next-hop, port) try: sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) except socket.error as err: print("Failed to create socket:") print(str(err)) exit() try: sock.bind((host, port)) except socket.error as err: print("Failed to bind:") print(str(err)) exit()
thismanager = plt.get_current_fig_manager() thismanager.window.wm_iconbitmap("icon.ico") except: pass whw, whh = 0.53, 1. ax1 = f.add_axes([0., 0., whw, whh]) ax2 = f.add_axes([whw + 0.05 * whw, 0., 1. - whw, 1 - 0.4 * whh]) ax3 = f.add_axes( [whw + 0.1 * whw, 1 - 0.45 * whh, 1. - whw - 0.1 * whw, 0.4 * whh]) ax4 = f.add_axes( [whw - 0.05 * whw, 1 - 0.8 * whh, 0.1 * whw, 0.8 * whh - 0.025 * whh]) ax5 = f.add_axes([0., 1 - 0.1 * whh, 0.2 * whw, 0.1 * whh]) x, factor = -1, 2 rightselection, edit = -1000, 1 selection, board, i_reader, variations = initialize() listlabels = [] bbox = ax1.get_window_extent().transformed(f.dpi_scale_trans.inverted()) wh0, sizewin = bbox.width, 1. com, warning, showhelp = False, False, False updateplot(ax1, ax2, ax3, ax4, ax5) active = True while active: if plt.get_fignums(): if not com: f.canvas.mpl_connect('key_press_event', on_key) f.canvas.mpl_connect('button_press_event', onclick) f.canvas.mpl_connect('button_release_event', onreleasedclick) f.canvas.mpl_connect('scroll_event', onscroll) f.canvas.mpl_connect('resize_event', resize) plt.waitforbuttonpress()
def cli_main(): if not os.path.exists(globals.zconf_home): print( colorprint( "ZConf directory not found. This could be the result of a botched installation/uninstallation - \nplease follow the installation instructions at https://github.com/varun-ramani/zconf to reinstall ZConf.", "red")) return if len(sys.argv) == 1: help.overview() if len(sys.argv) == 2: if sys.argv[1] == "help": help.overview() elif sys.argv[1] == "update": update.update() elif sys.argv[1] == "init": init.initialize() else: err_invalid_command(sys.argv[1]) if len(sys.argv) == 3: if sys.argv[1] == "help": help.command(sys.argv[2]) elif sys.argv[1] == "path": if sys.argv[2] == "view": path.view() else: err_invalid_command("path " + sys.argv[2]) elif sys.argv[1] == "alias": if sys.argv[2] == "view": alias.view() else: err_invalid_command("alias " + sys.argv[2]) elif sys.argv[1] == "plugin": if sys.argv[2] == "update": plugin.update() else: err_invalid_command("plugin " + sys.argv[2]) else: err_invalid_command(sys.argv[1]) if len(sys.argv) == 4: if sys.argv[1] == "path": if sys.argv[2] == "rm": path.remove_segment(sys.argv[3]) elif sys.argv[2] == "enable": path.enable_segment(sys.argv[3]) elif sys.argv[2] == "disable": path.disable_segment(sys.argv[3]) elif sys.argv[2] == "get": path.get_segment(sys.argv[3]) else: err_invalid_command("path " + sys.argv[2]) elif sys.argv[1] == "alias": if sys.argv[2] == "rm": alias.remove(sys.argv[3]) elif sys.argv[2] == "enable": alias.enable(sys.argv[3]) elif sys.argv[2] == "disable": alias.disable(sys.argv[3]) elif sys.argv[2] == "get": alias.get(sys.argv[3]) else: err_invalid_command("alias " + sys.argv[2]) elif sys.argv[1] == "plugin": if sys.argv[2] == "view": if sys.argv[3] == "all": plugin.view_all() elif sys.argv[3] == "local": plugin.view_local() elif sys.argv[3] == "remote": plugin.view_remote() else: err_invalid_command("plugin view " + sys.argv[3]) elif sys.argv[2] == "add": plugin.add(sys.argv[3]) elif sys.argv[2] == "rm": plugin.remove(sys.argv[3]) elif sys.argv[2] == "enable": plugin.enable(sys.argv[3]) elif sys.argv[2] == "disable": plugin.disable(sys.argv[3]) else: err_invalid_command("plugin " + sys.argv[2]) elif sys.argv[1] == "theme": if sys.argv[2] == "view": if sys.argv[3] == "all": theme.view_all() elif sys.argv[3] == "local": theme.view_local() elif sys.argv[3] == "remote": theme.view_remote() else: err_invalid_command("theme view " + sys.argv[3]) elif sys.argv[2] == "set": theme.set(sys.argv[3]) elif sys.argv[2] == "rm": theme.remove(sys.argv[3]) elif sys.argv[2] == "add": theme.add(sys.argv[3]) else: err_invalid_command("theme " + sys.argv[2]) else: err_invalid_command(sys.argv[1]) if len(sys.argv) == 5: if sys.argv[1] == "path": if sys.argv[2] == "set": path.set_segment(sys.argv[3], sys.argv[4]) else: err_invalid_command("path " + sys.argv[1]) elif sys.argv[1] == "alias": if sys.argv[2] == "set": alias.set(sys.argv[3], sys.argv[4]) else: err_invalid_command(sys.argv[1])
import socket import time import threading from graph import Graph from init import initialize from helper import * topo_lock = threading.Lock() topo = Graph() host, port = "127.0.0.1", 8800 initialize(topo) try: sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) except socket.error as err: print("Failed to create socket:") print(str(err)) exit() try: sock.bind((host, port)) except socket.error as err: print("Failed to bind:") print(str(err)) exit() # global_unpacker = MessageUnpacker() def push_route(packer, route):
def go_online(self): if initialize(self): return self.run() else: print("Node failed to initialize") return False
y.append(init.y0) i = init.t0 + deltaT # Ersten Zeitschritt ebenfalls "von Hand" machen counter = 1 # Counter wird benötigt, um auf das Array y zuzugreifen. Er symbolisiert die Position, auf welcher der nächste Wert eingefügt wird. # Time Loop while i <= init.T: time.append(i) y.append( time_integrator(f, y[counter - 1], deltaT, parameters) ) # y das Ergebnisarray des time-integrators hinzufügen. Also die neuesten berechneten Werte counter += 1 # Laufvariablen inkrementieren i += deltaT # i wird nur für Abbruchbedingung benutzt, man könnte auch die Anzahl der Schritte berechnen und diese über counter mitzählen und darüber abbrechen if __name__ == '__main__': init.initialize( ) # Model initialisieren. Mit Initial Values und Variablen für das Model, sowie Variablen für das Timestepping # und basierend auf diesen Variablen die passende Module laden if init.time_integrator_name == "euler_method": import euler_method as time_discretization elif init.time_integrator_name == "improved_euler_method": import improved_euler_method as time_discretization else: print('Thats not a valid model.') if init.f_name == "energy_balance_model": import energy_balance_model as climate_model elif init.f_name == "predator_prey_model": import predator_prey_model as climate_model else: print('Thats not a valid time integrator.')
import socket import time from init import initialize from helper import * neighbors = [] known_nodes = [] dis_vec = {} # destination: distance host, port = initialize(neighbors, known_nodes, dis_vec) routing_table = {} routing_table[(host, port)] = [("0.0.0.0", 0), 0] # (destination, next-hop, port) for i in range(len(neighbors)): routing_table[neighbors[i]] = (neighbors[i], i) try: sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) except socket.error as err: print("Failed to create socket:") print(str(err)) exit() try: sock.bind((host, port)) except socket.error as err: print("Failed to bind:") print(str(err)) exit() global_unpacker = MessageUnpacker()
batch_size = 5000 for key, keywords in event_keywords.iteritems(): apps = [event_tweet(t, keywords) for t in tweets] max_count = 0 max_ind = 0 for i in range(len(tweets) / batch_size + 1): s = sum(apps[(i-1) * batch_size: i * batch_size]) if s > max_count: max_count = s max_ind = i if max_ind not in event_cut_points: event_cut_points[max_ind] = [] event_cut_points[max_ind].append(key) initialize(tweets[:batch_size]) for i in range(1, len(tweets) / batch_size + 1): chunk_tweets = tweets[(i-1) * batch_size: i * batch_size] if i == 1: initialize(chunk_tweets) else: add_tweets_to_graph(chunk_tweets) if i in event_cut_points: g.prune(g.ts) for item in g.nw.items(): get_and_update(2, g.nw, item[0], g.ts) for kw_id in event_cut_points[i]:
def main(): file, outdir, sim_method, bhut_theta, out_method, delta_t, output_interval, t_total, savefig_dir = parse_args( ) ngal, m, e, r_min, ring_spacing, inclination_angle, n_rings, n_inner = parse_file( file) if not os.path.isabs(outdir): outdir = os.path.join(os.getcwd(), outdir) if not os.path.isabs(savefig_dir): savefig_dir = os.path.join(os.getcwd(), savefig_dir) nsteps = floor(t_total / delta_t) nout = round(output_interval / delta_t) n_particles = expected_particles(ngal, n_inner, n_rings) x, v, maxes = initialize(m, e, r_min, inclination_angle, n_rings, n_inner, ring_spacing, ngal, n_particles) a = zeros(shape=(n_particles, 3)) a = get_acceleration(x, a, m, ngal, n_particles) m = initialize_masses(m, n_particles) if sim_method == 'unpickle' and out_method == 'pickle': print('It makes no sense to unpickle and pickle') exit() if sim_method == 'barnes-hut': print(f'setting up barnes-hut, theta is {bhut_theta}') stream = barnes_pos_stream(x, v, a, m, n_particles, delta_t, nsteps, 2, max(maxes)) elif sim_method == 'massless': stream = massless_stream(x, v, a, m, ngal, n_particles, delta_t, nsteps) elif sim_method == 'unpickle': bhut_theta, delta_t, output_interval, t_total = unpickle_hyper_params( outdir) ngal, m, e, r_min, ring_spacing, inclination_angle, n_rings, n_inner = unpickle_params( outdir) print('unpickling params...') print(f'output_interval was {output_interval}') print(f'delta_t was {output_interval}') nsteps = floor(t_total / delta_t) nout = round(output_interval / delta_t) total_out = floor(nsteps / nout) print( f'with nstepts={nsteps} and nout={nout} expecting {total_out} files' ) stream = unpickle_stream(outdir, total_out) else: raise Exception(f'invalid simulation method: {sim_method}') print('running the simulation with:') print(f'simulation method: {sim_method}') print(f'barnes-hut theta: {bhut_theta}') print(f'output method: {out_method}') print(f't_total: {t_total}') print(f'delta_t: {delta_t}') print(f'output interval: {output_interval}') print(f'nsteps: {nsteps}') print(f'write every {nout} steps') print(f'ngal: {ngal}') if out_method == 'pickle': pickle_hyper_params(bhut_theta, delta_t, output_interval, t_total, outdir) pickle_params(ngal, m, e, r_min, ring_spacing, inclination_angle, n_rings, n_inner, outdir) t = 0 file_n = 0 print( f'with nsteps={nsteps} and nout={nout}, expecting {nsteps / nout} outputs' ) for x in stream: if t % nout == 0: print(f'pickling {file_n}/{floor(nsteps / nout)}') pickle_state(x, file_n, outdir) file_n += 1 t += 1 elif out_method == 'animate': print('starting the animation') anim = AnimatedScatter(stream, 1.01 * max(maxes), ngal, 250, delta_t * nout, savefig_dir)
from decision import decision from predict import predict np.random.seed(0) # Load the dataset out = dataset() X, y = out['X'], out['y'] # Set up the Neural Net nn_input_dim = X.shape[1] # input dimension nn_hdim = 3 # number of hidden variables nn_output_dim = 2 # two classes # Initial model model = initialize(nn_input_dim, nn_hdim, nn_output_dim) fig = plt.figure() ax = fig.add_subplot(111) plt.ion() fig.show() fig.canvas.draw() # Train a model reg_lambda = 0.01 epsilon = 0.01 num_passes = 1000 for i in range(0, num_passes): out = forward(model, X, y) z1, a1, probs, yhat = out['z1'], out['a1'], out['probs'], out['yhat'] model = backward(model, X, y, probs, a1, reg_lambda, epsilon)