def __init__(self, env, save_dirs, learning_rate=0.0001): BaseModel.__init__(self, input_shape=env.observation_space.shape, num_actions=env.action_space.n, save_dirs=save_dirs) self.env = env self.blueprint = { 'conv_layers': 3, 'filters': [32, 64, 64], 'kernel_sizes': [(8, 8), (4, 4), (3, 3)], 'strides': [(4, 4), (2, 2), (1, 1)], 'paddings': ['valid', 'valid', 'valid'], 'activations': ['relu', 'relu', 'relu'], 'dense_units': 512, 'dense_activation': 'relu' } self.local_model_save_path = os.path.join(self.save_path, 'local-wts.h5') self.local_model = NeuralNet(input_shape=self.input_shape, num_actions=self.num_actions, learning_rate=learning_rate, blueprint=self.blueprint).model
def __init__(self): BaseModel.__init__(self) self.dictionary = None self.model = None self.playlists = [] self.playlist_similarity = defaultdict(list) self.pids = [] #All playlist id
def __init__(self, opt): """Initialize the pix2pix class. Parameters: opt (Option class)-- stores all the experiment flags; needs to be a subclass of BaseOptions """ BaseModel.__init__(self, opt) # specify the training losses you want to print out. The training/test scripts will call <BaseModel.get_current_losses> self.loss_names = ['G', 'G_GAN', 'G_L1', 'D_real', 'D_fake'] # specify the images you want to save/display. The training/test scripts will call <BaseModel.get_current_visuals> # self.visual_names = ['real_A', 'fake_B', 'real_B'] self.visual_names = ['cloth_decoded', 'fakes_scaled', 'textures_unnormalized'] # specify the models you want to save to the disk. The training/test scripts will call <BaseModel.save_networks> and <BaseModel.load_networks> if self.is_train: self.model_names = ['G', 'D'] else: # during test time, only load G self.model_names = ['G'] # define networks (both generator and discriminator) self.net_G = define_G(opt.cloth_channels + 36, opt.texture_channels, 64, "unet_128", opt.norm, True, opt.init_type, opt.init_gain).to(self.device) if self.is_train: # define a discriminator; conditional GANs need to take both input and output images; Therefore, #channels for D is input_nc + output_nc self.net_D = define_D(opt.cloth_channels + 36 + opt.texture_channels, 64, opt.discriminator, opt.n_layers_D, opt.norm, opt.init_type, opt.init_gain).to(self.device) if self.is_train: # define loss functions use_smooth = True if opt.gan_label_mode == "smooth" else False self.criterionGAN = GANLoss(opt.gan_mode, smooth_labels=use_smooth).to(self.device) self.criterionL1 = torch.nn.L1Loss() # initialize optimizers; schedulers will be automatically created by function <BaseModel.setup>. self.optimizer_G = torch.optim.Adam(self.net_G.parameters(), lr=opt.lr, betas=(opt.beta1, 0.999)) self.optimizer_D = torch.optim.Adam(self.net_D.parameters(), lr=opt.lr, betas=(opt.beta1, 0.999))
def __init__(self, dim_konf, dim_data, atype, region): BaseModel.__init__(self, dim_konf, atype, region) n_hidden = 32 self.features = \ torch.nn.Sequential( torch.nn.Conv2d(1, n_hidden, kernel_size=(1, self.dim_konf + 4 + 4 + 4 + 2)), torch.nn.LeakyReLU(), torch.nn.Conv2d(n_hidden, n_hidden, kernel_size=(1, 1)), torch.nn.LeakyReLU(), torch.nn.Conv2d(n_hidden, n_hidden, kernel_size=(1, 1)), torch.nn.LeakyReLU(), torch.nn.MaxPool2d(kernel_size=(2, 1)), torch.nn.Conv2d(n_hidden, n_hidden, kernel_size=(1, 1)), torch.nn.LeakyReLU(), torch.nn.MaxPool2d(kernel_size=(2, 1)) ) self.value = \ torch.nn.Sequential( torch.nn.Linear(self.dim_cnn_features, 32), torch.nn.ReLU(), torch.nn.Linear(32, 32), torch.nn.ReLU(), torch.nn.Linear(32, 1) )
def __init__(self, dim_data, atype, region, problem_name): BaseModel.__init__(self, atype, region, problem_name) self.konf_net = \ nn.Sequential( torch.nn.Linear(self.n_konfs*self.dim_konf, self.n_hidden), nn.ReLU(), torch.nn.Linear(self.n_hidden, self.n_hidden), nn.ReLU() ) self.pose_net = \ nn.Sequential( torch.nn.Linear(self.dim_pose_ids, self.n_hidden), nn.ReLU(), torch.nn.Linear(self.n_hidden, self.n_hidden), nn.ReLU() ) dim_actions = dim_data self.action_net = \ nn.Sequential( torch.nn.Linear(dim_actions, self.n_hidden), nn.ReLU(), torch.nn.Linear(self.n_hidden, self.n_hidden), nn.ReLU() ) dim_input = self.n_hidden * 3 self.output = \ nn.Sequential( torch.nn.Linear(dim_input, self.n_hidden), nn.ReLU(), torch.nn.Linear(self.n_hidden, 1) )
def __init__(self, item): BaseModel.__init__(self, item) defs.StoppableThread.__init__(self) self._scheduler = schedule.Scheduler() job = self._scheduler.every(self.schedule['interval']) job.unit = self.schedule['unit'] if len(self.schedule['at']) > 0: job.at(self.schedule['at'][0]) job.do(self.run_job) """
def __init__(self): BaseModel.__init__(self)
def __init__(self): BaseModel.__init__(self) self.user_similarity = defaultdict(list) self.user_tag_distrib = defaultdict(dict)
def __init__(self): BaseModel.__init__(self) self.item_similarity = { } # {itemid:[(sim_item,similarity)]} sorted by similarity
def __init__(self): BaseModel.__init__(self) self.user_similarity = defaultdict(dict) self.userCF = UserCF() self.userTag = UserTagCF() self.userLda = UserLDA()
def __init__(self): BaseModel.__init__(self) self.dictionary = None self.model = None self.user_similarity = defaultdict(list)
def __init__(self): BaseModel.__init__(self) self.popular_list = []
def __init__(self): BaseModel.__init__(self) self.user_similarity = defaultdict(list) # {uid:{sim_id:similarity}}
def __init__(self): BaseModel.__init__(self) self.item_similarity = {} # {itemid:[(sim_item,similarity)]} sorted by similarity