def __init__(self, opt, logger): super().__init__(opt, logger) self.net_N = opt.net_N self.x_dim = opt.x_dim self.z_dim = opt.z_dim self.n_classes = opt.n_classes self.p_drop = opt.p_drop self.modality = opt.modality self.n_modality = len(self.modality) self.clf_weights = opt.clf_weights assert len(self.x_dim) == self.n_modality # check the length of x_dim # init networks self.net_q = [None] * self.n_modality for i in range(self.n_modality): self.net_q[i] = Q_net(self.net_N, self.x_dim[i], self.z_dim, self.p_drop) self.net_c = C_net(self.net_N, self.z_dim * self.n_modality, self.n_classes, self.p_drop) self._nets = self.net_q + [self.net_c] # optimizers self.optimizer_q = [None] * self.n_modality for i in range(self.n_modality): self.optimizer_q[i] = self.optimizer(self.net_q[i].parameters(), lr=opt.lr, **self.optimizer_params) self.optimizer_c = self.optimizer(self.net_c.parameters(), lr=opt.lr, **self.optimizer_params) self._optimizers = self.optimizer_q + [self.optimizer_c] # scheduler self.scheduler_q = [None] * self.n_modality for i in range(self.n_modality): self.scheduler_q[i] = self.scheduler(self.optimizer_q[i], **self.scheduler_params) self.scheduler_c = self.scheduler(self.optimizer_c, **self.scheduler_params) self._schedulers = self.scheduler_q + [self.scheduler_c] # general self.opt = opt self._metrics = [ 'loss_survival', 'c_index' ] # log the autoencoder loss and the classification loss if opt.log_time: self._metrics += ['t_survival'] # init variables #self.input_names = ['features', 'labels'] self.init_vars(add_path=True) # init weights for i in range(self.n_modality): self.init_weight(self.net_q[i]) self.init_weight(self.net_c)
def __init__(self, opt, logger): super().__init__(opt, logger) self.net_N = opt.net_N self.x_dim = opt.x_dim self.z_dim = opt.z_dim self.n_classes = opt.n_classes self.p_drop = opt.p_drop self.modality = opt.modality self.clf_weights = opt.clf_weights # init networks self.net_q = Q_net(self.net_N, self.x_dim, self.z_dim, self.p_drop) self.net_p = P_net(self.net_N, self.x_dim, self.z_dim, self.p_drop) self.net_c = C_net(self.net_N, self.z_dim, self.n_classes, self.p_drop) self._nets = [self.net_q, self.net_p, self.net_c] # optimizers # self.optimizer and self.optimizer_params have been initialized in netinterface self.optimizer_q = self.optimizer(self.net_q.parameters(), lr=opt.lr, **self.optimizer_params) self.optimizer_p = self.optimizer(self.net_p.parameters(), lr=opt.lr, **self.optimizer_params) self.optimizer_c = self.optimizer(self.net_c.parameters(), lr=opt.lr, **self.optimizer_params) self._optimizers = [ self.optimizer_q, self.optimizer_p, self.optimizer_c ] # schedulers # self.scheduler and self.scheduler_params have been initialized in netinterface self.scheduler_q = self.scheduler(self.optimizer_q, **self.scheduler_params) self.scheduler_p = self.scheduler(self.optimizer_p, **self.scheduler_params) self.scheduler_c = self.scheduler(self.optimizer_c, **self.scheduler_params) self._schedulers = [ self.scheduler_q, self.scheduler_p, self.scheduler_c ] # general self.opt = opt self._metrics = [ 'loss_mse', 'loss_survival', 'c_index' ] # log the autoencoder loss and the classification loss if opt.log_time: self._metrics += ['t_recon', 't_survival'] # init variables self.init_vars(add_path=True) # init weights self.init_weight(self.net_q) self.init_weight(self.net_p) self.init_weight(self.net_c)
def __init__(self, opt, logger): super().__init__(opt, logger) self.net_N = opt.net_N self.x_dim = opt.x_dim self.z_dim = opt.z_dim self.n_classes = opt.n_classes self.p_drop = opt.p_drop self.modality = opt.modality self.n_modality = len(self.modality) # init networks self.net_q = Q_net(self.net_N, self.x_dim, self.z_dim, self.p_drop) self.net_p = P_net(self.net_N, self.x_dim, self.z_dim, self.p_drop) self.net_c = C_net(self.net_N, self.z_dim, self.n_classes, self.p_drop) self._nets = [self.net_q, self.net_p, self.net_c] # optimizers self.optimizer_q = self.optimizer(self.net_q.parameters(), lr=opt.lr, **self.optimizer_params) self.optimizer_p = self.optimizer(self.net_p.parameters(), lr=opt.lr, **self.optimizer_params) self.optimizer_c = self.optimizer(self.net_c.parameters(), lr=opt.lr, **self.optimizer_params) self._optimizers = [ self.optimizer_q, self.optimizer_p, self.optimizer_c ] #schedulers self.scheduler_q = self.scheduler(self.optimizer_q, **self.scheduler_params) self.scheduler_p = self.scheduler(self.optimizer_p, **self.scheduler_params) self.scheduler_c = self.scheduler(self.optimizer_c, **self.scheduler_params) self._schedulers = [ self.scheduler_q, self.scheduler_p, self.scheduler_c ] # general self.opt = opt self._metrics = [ 'loss_mse', 'loss_clf' ] # log the autoencoder loss and the classification loss if opt.log_time: self._metrics += ['t_recon', 't_clf'] # init variables #self.input_names = ['features', 'labels'] self.init_vars(add_path=True) # init weights self.init_weight(self.net_q) self.init_weight(self.net_p) self.init_weight(self.net_c)
def __init__(self, opt, logger): super().__init__(opt, logger) self.net_N = opt.net_N self.x_dim = opt.x_dim self.z_dim = opt.z_dim self.n_classes = opt.n_classes self.p_drop = opt.p_drop self.modality = opt.modality[ 0] # get the fisrt element since changed this argument to list self.clf_weights = opt.clf_weights # init networks self.net_q = Q_net(self.net_N, self.x_dim, self.z_dim, self.p_drop) self.net_c = C_net(self.net_N, self.z_dim, self.n_classes, self.p_drop) self._nets = [self.net_q, self.net_c] # optimizers # self.optimizer and self.optimizer_params have been initialized in netinterface self.optimizer_q = self.optimizer(self.net_q.parameters(), lr=opt.lr, **self.optimizer_params) self.optimizer_c = self.optimizer(self.net_c.parameters(), lr=opt.lr, **self.optimizer_params) self._optimizers = [self.optimizer_q, self.optimizer_c] # schedulers # self.scheduler and self.scheduler_params have been initialized in netinterface self.scheduler_q = self.scheduler(self.optimizer_q, **self.scheduler_params) self.scheduler_c = self.scheduler(self.optimizer_c, **self.scheduler_params) self._schedulers = [self.scheduler_q, self.scheduler_c] # general self.opt = opt self._metrics = [ 'loss_clf' ] # log the autoencoder loss and the classification loss if opt.log_time: self._metrics += ['t_clf'] # init variables self.init_vars(add_path=True) # init weights self.init_weight(self.net_q) self.init_weight(self.net_c)