model = model_util.load(model_to_load, filepath) #To prevent any possible corruption between cycles, just reload and #reprocess the data, including resorting data, classes = emnist.get(balanced_set) x, y, val_x, val_y = data_util.validation_split(data['x'], data['y'], validation_split) x, y = emnist.mean_sort(x, y, classes, task_count) #Convert test data to be used in model val_x, val_y = data_util.prep(val_x, val_y, classes) test_x, test_y = data_util.prep(data['test_x'], data['test_y'], classes) #Set up syllabus which handles splitting into tasks syllabus = Syllabus( training_data =(x,y), epochs=epochs, task_amount=task_count, weightings=distribution, ) #Until we have finished training while not syllabus.training_complete(): #Get our next task and prep it x, y = syllabus.next() x, y = data_util.prep(x, y, classes) print("epoch : {0}\ttask: {1}".format(syllabus.current_epoch, syllabus.current_task_index)) model.fit( x=x, y=y, batch_size=batch_size, epochs=1,
def syllabi(self): from syllabus import Syllabus return Syllabus.query(ancestor = self.key).fetch()
def post(self): term = self.current_term subject = str(self.request.get('subjectSelect')) number = int(self.request.get('courseNumber')) section = int(self.request.get('sectionNumber')) info = Info(subject = subject, number = number, section = section) syllabus = Syllabus(parent = term.key, info = info) if number < 10: number = '00' + str(number) elif number < 100: number = '0' + str(number) else: number = str(number) if section < 10: section = '00' + str(section) elif section < 100: section = '0' + str(section) else: section = str(section) course_list = WebScraper.scrapeCourseNames(str(term.semester), int(term.year), subject) course_name = None for c in course_list: if WebScraper.getCourseSubjectFromCourseName(c) == subject and WebScraper.getCourseNumberFromCourseName(c) == number: course_name = c break if course_name: syllabus.info.title = WebScraper.getCourseTitleFromCourseName(course_name) sections_list = WebScraper.scrapeCourseSections(str(term.semester), int(term.year), course_name) course_section = None for s in sections_list: section = WebScraper.getSectionFromCourseSection(s) if section == 'LEC ' + syllabus.info.section_string or section == 'LAB ' + syllabus.info.section_string: course_section = s break if course_section: room = WebScraper.getRoomFromCourseSection(course_section) if room: syllabus.info.building = room.split()[0] syllabus.info.room = room.split()[1] syllabus.info.days = WebScraper.getMeetDaysFromCourseSection(course_section) time = WebScraper.getMeetTimeFromCourseSection(course_section) if time: syllabus.info.start = self.military(time.split('-')[0]) syllabus.info.end = self.military(time.split('-')[1]) instructor = WebScraper.getInstructorFromCourseSection(course_section) if instructor: syllabus.prime = instructor dates = WebScraper.getDatesFromCourseSection(course_section) if dates: syllabus.info.startDate = dates.split('-')[0] syllabus.info.endDate = dates.split('-')[1] syllabus.put() self.session['syllabus'] = syllabus.key.urlsafe() self.redirect('/')