def ferr(label, pred): pred = pred.ravel() label = label.ravel() return np.abs(label - (pred > 0.5)).sum() / label.shape[0] lr = 0.0005 beta1 = 0.5 batch_size = 100 rand_shape = (batch_size, 100) num_epoch = 100 data_shape = (batch_size, 1, 28, 28) context = mx.gpu() logging.basicConfig(level=logging.DEBUG, format='%(asctime)-15s %(message)s') sym_gen = generator.dcgan28x28(oshape=data_shape, ngf=32, final_act="sigmoid") encoder = encoder.lenet() encoder = ops.minibatch_layer(encoder, batch_size, num_kernels=100) gmod = module.GANModule(sym_gen, symbol_encoder=encoder, context=context, data_shape=data_shape, code_shape=rand_shape) gmod.init_params(mx.init.Xavier(factor_type="in", magnitude=2.34)) gmod.init_optimizer(optimizer="adam", optimizer_params={ "learning_rate": lr, "wd": 0.,
def ferr(label, pred): pred = pred.ravel() label = label.ravel() return np.abs(label - (pred > 0.5)).sum() / label.shape[0] lr = 0.0005 beta1 = 0.5 batch_size = 100 rand_shape = (batch_size, 100) num_epoch = 100 data_shape = (batch_size, 1, 28, 28) context = mx.gpu() logging.basicConfig(level=logging.DEBUG, format='%(asctime)-15s %(message)s') sym_gen = generator.dcgan28x28(oshape=data_shape, ngf=32, final_act="sigmoid") encoder = encoder.lenet() encoder = ops.minibatch_layer(encoder, batch_size, num_kernels=100) gmod = module.GANModule( sym_gen, symbol_encoder=encoder, context=context, data_shape=data_shape, code_shape=rand_shape) gmod.init_params(mx.init.Xavier(factor_type="in", magnitude=2.34)) gmod.init_optimizer( optimizer="adam", optimizer_params={