def post(self): args_dict = {} for field_name in FIELDS: field_value = self.request.get(field_name, None) if field_value is None: self.response.status = '400 - Bad request (missing parameter)' return args_dict[field_name] = self.request.get(field_name, None) map_to_insert = model.Map(**args_dict) index = search.Index(name=MAP_INDEX) index.put(map_to_insert)
def PutTestMapJson(self, map_id, map_root, maproot_json, owner='test1', domain='gmail.test'): """Stores a test map from a given maproot in the datastore.""" map_object = model.Map(model.MapModel( key_name=map_id, owners=[owner], editors=[], viewers=[], domain=domain, domains=[domain], domain_role=None, world_readable=True)) new_version = model.MapVersionModel( parent=map_object.model, maproot_json=maproot_json) # Update the MapModel from fields in the MapRoot JSON. map_object.model.title = map_root.get('title', '') map_object.model.description = map_root.get('description', '') map_object.model.current_version = new_version.put() map_object.model.put()
def PutTestMap(self, map_id, file_name, owner='test1', domain='gmail.test'): """Stores a test map in the datastore.""" json_data = ReadFile(file_name) map_object = model.Map( model.MapModel(key_name=map_id, owners=[owner], editors=[], viewers=[], domain=domain, domains=[domain], domain_role=None, world_readable=True)) map_root = json.loads(json_data) # validate the JSON first new_version = model.MapVersionModel(parent=map_object.model, maproot_json=json_data) # Update the MapModel from fields in the MapRoot JSON. map_object.model.title = map_root.get('title', '') map_object.model.description = map_root.get('description', '') map_object.model.current_version = new_version.put() map_object.model.put()
import model import view c = model.Character("characterdata.json") c.vision=3 m = model.Map("mapdata_big.json") gv = view.GameView(m,c) gv.mainloop()
def __init__(self, in_path_photo=None, in_path_oil=None, autoencoder_path=None, num_epochs=100, batch_size=50, learning_rate=0.0002, recon_loss_weight=10, penalty_coef=10, verbose=True): """ This class implements the siamese architecture. :param in_path_photo: (string) the file path indicating the location of the training data for photographs. :param in_path_oil: the file path indicating the location of the training data for oil. :param autoencoder_path: (string) the path where the save files of the autoencoders are stored. :param num_epochs: (int) the number of epochs. :param batch_size: (int) the batch size. :param learning_rate: (int) the learning rate for the Adam optimizer. :param recon_loss_weight: (float) the parameter that scales the cycle consistency / reconstruction loss (beta) :param penalty_coef: (float) the penalty coefficient for the Wasserstein GAN (lambda) :param verbose: (boolean) if true, the training process is printed to console """ self.device = torch.device( 'cuda' if torch.cuda.is_available() else 'cpu') self.use_cuda = torch.cuda.is_available() self.in_path_photo = in_path_photo self.in_path_oil = in_path_oil self.num_epochs = num_epochs self.batch_size = batch_size self.learning_rate = learning_rate self.recon_loss_weight = recon_loss_weight self.penalty_coef = penalty_coef self.verbose = verbose self.start_epoch = 1 self.d_photo_losses = [] self.d_oil_losses = [] self.g_photo_losses = [] self.g_oil_losses = [] self.photo_rec_losses = [] self.oil_rec_losses = [] self.auto_photo = autoencoder.Autoencoder() self.auto_photo.load(autoencoder_path + 'autoencoder_photo_20.pth') self.auto_photo.eval() self.auto_oil = autoencoder.Autoencoder() self.auto_oil.load(autoencoder_path + 'autoencoder_oil_20.pth') self.auto_oil.eval() self.map_v_to_u = model.Map().cuda() if self.use_cuda else model.Map() self.map_u_to_v = model.Map().cuda() if self.use_cuda else model.Map() self.v_to_u_optimizer = torch.optim.Adam(self.map_v_to_u.parameters(), lr=learning_rate, betas=(0.5, 0.9)) self.u_to_v_optimizer = torch.optim.Adam(self.map_u_to_v.parameters(), lr=learning_rate, betas=(0.5, 0.9)) self.discriminator_photo = model.Discriminator().cuda( ) if self.use_cuda else model.Discriminator() self.discriminator_oil = model.Discriminator().cuda( ) if self.use_cuda else model.Discriminator() self.d_photo_optimizer = torch.optim.Adam( self.discriminator_photo.parameters(), lr=learning_rate, betas=(0.5, 0.9)) self.d_oil_optimizer = torch.optim.Adam( self.discriminator_oil.parameters(), lr=learning_rate, betas=(0.5, 0.9))