示例#1
0
    def save(self, filename):
        """Saves the text map and serialized entities"""
        folder = self.get_folder()
        check_dir(folder)
        file_path = folder + sep + filename
        config = SafeConfigParser()

         # Add the save header
        s = self.__cfg_header
        config.add_section(s)
        config.set(s, "version", str(WORLD_VERSION))

         # Serialize and save each entity
        s = self.__cfg_entities
        config.add_section(s)
        for entity in self.entity_manager.get_entities().values():
            uid = entity.get_uid()
            data = self.entity_manager.serialize_entity(uid)
            config.set(s, str(uid), ord_bytes(data))

         # Add the map content
        s = self.__cfg_map
        config.add_section(s)
        for x, y in enumerate(self.map):
            config.set(s, str(x), y)

        cfg_file = open(file_path, "w")
        config.write(cfg_file)
        cfg_file.close()
        self.redraw_map = True
        self.redraw_minimap = True
        self.__log.info("Saved world %s" % filename)
示例#2
0
 def data_problem(self, data, info = "Problem with data"):
     """Warnings about problem with data"""
     self.log.error("%s: %s" % (info, format_bytes(data)))
     if data != None:
         fail_folder = get_base_dir() + sep + UDP_FOLDER + sep
         check_dir(fail_folder)
         filename = fail_folder + str(round_int(time())) + ".udp"
         fail = open(filename, "w")
         fail.write(data)
         fail.close()
示例#3
0
 def list(self):
     """Returns the maps in current selected folder"""
     files = {}
     files_names = []
     files_full = []
     folder = self.get_folder()
     check_dir(folder)
     for name in listdir(folder):
         full = folder + sep + name
         if isfile(full):
             files[name] = full
             files_names.append(name)
             files_full.append(full)
     return files, files_names, files_full
示例#4
0
                        type=int,
                        default=5,
                        help='number of classes in one training task')

    parser.add_argument('--save-path', default='/data/save_models/...')
    parser.add_argument('--gpu', default='0')

    parser.add_argument('--episodes-per-batch',
                        type=int,
                        default=8,
                        help='number of episodes per batch')

    opt = parser.parse_args()

    set_gpu(opt.gpu)
    check_dir('./experiments/')
    check_dir(opt.save_path)

    log_file_path = os.path.join(opt.save_path, "train_log.txt")
    log(log_file_path, str(vars(opt)))

    (embedding_net, cls_head) = get_model(opt)

    #------------------------------------------
    dataset_train = tieredImageNet(phase='train')
    dataset_val = tieredImageNet(phase='val')
    data_loader = FewShotDataloader

    dloader_train = data_loader(
        dataset=dataset_train,
        nKnovel=opt.train_way,