Example #1
0
    def __init__(self, name, parent=None):
        """
		path is a tab-delimited curriculum data file`
		"""

        self.name = name
        config_data = courses_config[self.name]

        self.orgEntity = config_data['orgEntity']
        self.orgKey = config_data['orgKey']

        TopicRecord.dowrites = 1
        ChapterRecord.dowrites = 1

        BackPackModelObject.__init__(self, parent)

        # curriculum children are Unit instances
        self.curriculum = Curriculum(self.name)
Example #2
0
class Database:
    def __init__(self):
        self.db = {}
        self.add_user('guest')
        self.curriculum = Curriculum()

    def has_user(self, username):
        return username in self.db

    def add_user(self, username):
        user = {}
        user['name'] = username
        user['level'] = 1
        user['progress'] = 0
        user['feedback'] = 'flag'  # 'backtranslate', 'recast'
        self.db[username] = user

    def get_user_profile(self, username):
        user = self.db[username]
        progress_report = self.curriculum.get_progress_report(user)
        progress_report = json.dumps(progress_report)
        return progress_report

    def update_user(self, username, attr, val):
        self.db[username][attr] = val

    def get_user_attr(self, username, attr):
        return self.db[username][attr]

    def get_user_rulefile(self, username):
        level_num = self.db[username]['level']
        return self.curriculum.get_rulefile(level_num)

    def increment_user_progress(self, username):
        self.db[username]['progress'] += 1

        level_num = self.db[username]['level']
        total_progress = self.curriculum.get_level_rep(level_num)
        if self.db[username]['progress'] == total_progress:
            self.db[username]['level'] += 1
            self.db[username]['progress'] = 0
Example #3
0
 def __init__(self, config_file, config_dir, output_dir, model_file=None, curriculum_file=None):
     self.name = config_file[:-5]
     self.activated = True
     self.cfg  = lambda *args, **kwargs: get_config(config_file, *args, config_dir=config_dir, **kwargs)
     self.model_file = model_file
     # self.model = RLearner(self.name, self.cfg, load_file=model_file)
     self.model = None
     self.curriculum = Curriculum(self.cfg, self.name, load_file=curriculum_file)
     self.total_episodes = 0
     self.stats_filename = output_dir+self.name+'.csv'
     self.completed = False
     print(self.name)
Example #4
0
class OrgConfig(BackPackModelObject):
    """

	"""
    xmlRecord_constructor = OrgConfigMetadataRecord

    def __init__(self, name, parent=None):
        """
		path is a tab-delimited curriculum data file`
		"""

        self.name = name
        config_data = courses_config[self.name]

        self.orgEntity = config_data['orgEntity']
        self.orgKey = config_data['orgKey']

        TopicRecord.dowrites = 1
        ChapterRecord.dowrites = 1

        BackPackModelObject.__init__(self, parent)

        # curriculum children are Unit instances
        self.curriculum = Curriculum(self.name)

    def getChildren(self):
        """
		ASSUMPTION: we only have a single child curriculum
		"""
        return {self.curriculum.getId(): self.curriculum}

    def getRecord(self):
        """
		get template record, and then populate with chapter data
		NOTEs:
			- 'object' is set in template
			- ID has to be set before the record can be written
		"""
        if not self.record:
            rec = BackPackModelObject.getRecord(self)

            rec.setTitle(self.name)
            rec.setOrgEntity(self.orgEntity, self.orgKey)

            curriculumEl = rec.makeCurriculumElement(self.curriculum)
            rec.addCurriculumElement(curriculumEl)

            self.record = rec
            self.write()

        return self.record
Example #5
0
if __name__ == '__main__':
    cfg = lambda *args, **kwargs: get_config(CONFIG_FILE, *args, **kwargs)

    modes = {
        'Training - Simulated, no Display': (True, False, True),
        'Training - Simulated w/ Display': (True, True, True),
        'Training - Real w/ Display': (True, True, False),
        'Demonstration - Simulated': (False, True, True),
        'Demonstration - Real': (False, True, False)
    }
    set_training, set_display, set_simulated = modes[ask_options(
        'Select execution mode:', list(modes.keys()))]

    model = RLearner(MODEL_NAME, cfg)
    disp = (Display(model) if set_display else None)
    curriculum = Curriculum(cfg, model.name())
    if set_training:
        plot_stats = ask_yn('Plot stats?')
        show_qsummary = ask_yn('Show Q-Summary?')
        if cfg('training', 'train_on_history'):
            model.train_on_history(batch_size=cfg('training', 'history',
                                                  'batch_size'),
                                   batches=cfg('training', 'history',
                                               'batches'),
                                   epochs=cfg('training', 'history', 'epochs'))
        train_model(model,
                    curriculum,
                    cfg,
                    initial_episode=model.start_episode,
                    display=disp,
                    simulated=set_simulated,
Example #6
0
num_neurons_per_hidden = 50
max_updates_per_env_step = 10
batch_size = 32
lrate = 1e-4
# replay_start_size = (num_episodes // 20) * max_steps_per_episode
# replay_memory_size = 10 * replay_start_size
disable_saving = True
sync_mode = True
portNb = 19999

curr_args = dict(curriculum=curriculum,
                 task=task,
                 # max_steps_per_episode=max_steps_per_episode,
                 # num_episodes=num_episodes,
                 max_total_transitions=max_total_transitions,
                 num_hidden_layers=num_hidden_layers,
                 num_neurons_per_hidden=num_neurons_per_hidden,
                 batch_size=batch_size,
                 lrate=lrate,
                 testing_scripts=testing_scripts,  # ##
                 max_updates_per_env_step=max_updates_per_env_step,
                 # replay_start_size=replay_start_size,
                 # replay_memory_size=replay_memory_size,
                 disable_saving=disable_saving,
                 sync_mode=sync_mode,
                 portNb=portNb,
                 )

curr = Curriculum(**curr_args)
no_curriculum_results_dict = curr.run()
Example #7
0
                recommended.append(v)
                total_hours += v_credits

        n_smts += 1
        print(str(n_smts) + "º semestre:")
        for course in recommended:
            print("{} ".format(course), end='')
        print("\n")

        for course in recommended:
            g.remove_vertex(course)


### RUN ###

c = Curriculum()
g = c.graph

print("Ordem topológica do currículo:")
print(g.get_topological_sorting())
print("*" * 80, end='\n\n')

print("Quantos semestres você já cursou?")
n_smts = int(input(""))

print(
    "Digite o código das disciplinas nas quais você já foi aprovado (ine5413, por exemplo):"
)
print("Digite 'fim' para finalizar a inserção")
completed = read_courses()
for course in completed:
Example #8
0
critic_activations = np.append(np.repeat(tf.nn.relu, n_hidden_layers),
                               PARAMS["critic_activation"])

actor_layers = (actor_widths, actor_activations)
critic_layers = (critic_widths, critic_activations)

n_ICM_size = PARAMS["n_ICM_size"]
n_ICM_layers = PARAMS["n_ICM_layers"]
n_features = PARAMS["n_features"]

forward_widths = np.append(np.repeat(n_ICM_size, n_ICM_layers), n_features)
backward_widths = np.append(np.repeat(n_ICM_size, n_ICM_layers), n_actions)
forward_activations = np.repeat(PARAMS["forward_activation"], n_ICM_layers + 1)
backward_activations = np.repeat(PARAMS["backward_activation"],
                                 n_ICM_layers + 1)

forward_layers = (forward_widths, forward_activations)
backward_layers = (backward_widths, backward_activations)

LAYERS = (actor_layers, critic_layers)
ICM_LAYERS = (forward_layers, backward_layers)

if __name__ == '__main__':
    tf.reset_default_graph()

    curriculum = Curriculum(PARAMS,
                            TASKS,
                            LAYERS,
                            ICM_LAYERS,
                            build_graph=GRAPH_PATH)
    curriculum.run()
Example #9
0
 def __init__(self):
     self.db = {}
     self.add_user('guest')
     self.curriculum = Curriculum()
Example #10
0
    from train_model import train_model
    from run_mission import Mission, run_mission

    if sys.version_info[0] == 2:
        sys.stdout = os.fdopen(sys.stdout.fileno(), 'w',
                               0)  # flush print output immediately
    else:
        print = functools.partial(print, flush=True)

    cfg = lambda *args, **kwargs: get_config(options.model_name, *args, **
                                             kwargs)

    model = RLearner(options.model_name, cfg, auto_latest=options.latest)
    disp = (Display(model) if options.display else None)
    curriculum = Curriculum(cfg, model.name(), auto_latest=options.latest)
    if options.training:
        if cfg('training', 'train_on_history'):
            model.train_on_history(batch_size=cfg('training', 'history',
                                                  'batch_size'),
                                   batches=cfg('training', 'history',
                                               'batches'),
                                   epochs=cfg('training', 'history', 'epochs'))
        train_model(model,
                    curriculum,
                    cfg,
                    initial_episode=model.start_episode,
                    display=disp,
                    simulated=options.simulated,
                    plot_stats=options.plot,
                    show_qsummary=options.qsummary)
Example #11
0
    disable_saving=disable_saving,
    sync_mode=sync_mode,
    portNb=portNb,
)

if load_no_curriculum_prev_results:
    no_curr_sparse_folder_name = exp_no_curr_sparse_folder_name
    no_curr_shap_folder_name = exp_no_curr_shaping_folder_name
    no_curr_shap_results_dict = get_no_curr_prev_runs(
        serialized_no_curr_shaping_path)
    no_curr_sparse_results_dict = get_no_curr_prev_runs(
        serialized_no_curr_sparse_path)

else:
    curr_args.update(dict(curriculum=no_curriculum_shaping))
    no_curr_shap = Curriculum(**curr_args)
    no_curr_shap_results_dict = no_curr_shap.run()
    no_curr_shap_folder_name = no_curr_shap.folder_name

    curr_args.update(dict(curriculum=no_curriculum_sparse))
    no_curr_sparse = Curriculum(**curr_args)
    no_curr_sparse_results_dict = no_curr_sparse.run()
    no_curr_sparse_folder_name = no_curr_sparse.folder_name

for curriculum in Curriculums:
    curr_args.update(dict(curriculum=curriculum))
    curr = Curriculum(**curr_args)
    curriculum_results_dict = curr.run()
    curriculum_folder_name = curr.folder_name
    savePlots(no_curr_shap_folder_name, no_curr_shap_results_dict,
              no_curr_sparse_folder_name, no_curr_sparse_results_dict,