padding

WGAN-GP与WGAN及GAN的比较

為{幸葍}努か 提交于 2019-12-05 10:51:53
以下为MNIST测试,主要为了构建模型,只跑了,少量epoch,效果如下: WGAN 2个epoch wgan-gp 6个epoch gan 10个epoch 有时间可以多跑几轮,这里就不展示了。 代码如下 from datetime import datetime import os import matplotlib.pyplot as plt import numpy as np import tensorflow as tf from six.moves import xrange from tensorflow.examples.tutorials.mnist import input_data mnist = input_data.read_data_sets("MNIST_data",one_hot=True) data= mnist.train.images#(55000,784) def Save_genImages(gen, epoch): r,c = 10,10 fig,axs = plt.subplots(r,c) cnt = 0 print(gen.shape) for i in range(r): for j in range(c): axs[i,j].imshow(gen[cnt][:,:],cmap='Greys_r') axs[i,j].axis(

Indexing into arrays of arbitrary rank in C#

风格不统一 提交于 2019-12-05 10:45:43
I need to iterate over an array of arbitrary rank. This is for both reading and writing, so GetEnumerator will not work. Array.SetValue(object, int) doesn't work on multidimensional arrays. Array.SetValue(object, params int[]) would require excessive arithmetic for iterating through the multidimensional space. It would also require dynamic invocation to get around the params part of the signature. I'm tempted to pin the array and iterate over it with a pointer, but I can't find any documentation that says that multidimensional arrays are guaranteed to be contiguous. If they have padding at the

Windows下Markdown编辑器闲聊

∥☆過路亽.° 提交于 2019-12-05 10:41:18
写在最前 自从我入了 Markdown 的坑之后就完全深深地爱上了这种写作方式,语法简单,排版漂亮。不管是用来日常写作、发布文章还是用来做演示都可以。 要是说到适合平常使用的编辑器的话,在线的有 简书 (不说有道云是因为真的很难用),Mac的话有 Mou 和 Macdown 。 但是Windows下的话选择就比较多,因为就我自己来说,没有一款是让自己最满意的,不像在Mac平台,就以上两种,随便哪个都用着很舒服。 在这里就说自己平常最喜欢用的两个,可以说是一套解决方案吧。 MarkdownPad 2 这是到现在我在Windows下发现的功能最完善的一款编辑器。但是唯一的缺点,就是真的自带的样式表比较丑和渲染处理器太不给力。 刚开始时候的界面是这样的: 也不能说是很丑吧,如果是刚开始使用的话也无所谓。但是在用过以上推荐过的非win平台的编辑器之后,看到这款编辑器的界面真的是有点生理不适。 但是还好这款编辑器对于编辑窗口提供了简单的设置,也有代码高亮。虽然自带的样式表很丑但还好是可编辑的。 至于渲染模式的话,渲染效果最好的是在线的 Github风格 ,如果觉得卡可以选择离线模式,其他的渲染模式选项可以不考虑。 这是改造过后的效果: 感觉还好,改造过后视力已基本恢复。我自己的改造配方如下: 编辑器外观设置 Markdown处理器 样式表 至于这个的话,可以自己写,也可以去网上找别人分享的。

HTML5 Table cell padding - different in browsers

筅森魡賤 提交于 2019-12-05 10:23:38
问题 I've broken this down to a fairly simple example. For me, it looks different in Chrome 7.0 than it does in Firefox 3.6.12. IE 9 beta looks like Chrome. I'd like to be able to set padding on the TD, and have it render with the same height in all browsers. Currently, with the 10px top padding, the cells in Chrome look taller than in Firefox. I've tried using Eric's reset css, it doesn't change the result Any ideas why these are being rendered differently? An example of how it looks is here -

[GAN01]GAN原理介绍并使用Keras实现DCGAN基于Mnist数据集的图像生成

别等时光非礼了梦想. 提交于 2019-12-05 09:55:15
前言 打算开坑实现一系列GAN,并基于这些模型对GAN的原理进行深入理解与挖掘。 第一篇是DCGAN。 理论部分 GAN的原理 从图中可以看到,GAN分为两部分,生成器和辨别器。 生成器与辨别器 生成器的目的是利用噪音生成以假乱真的图片,因此,其输入是无意义的噪音,输出是利用该噪音生成的图片。 辨别器的目的是区分出生成器生成的图片与真正的图片,因此,其输入是两种图片,输出是两种图片对应的种类(fake or real)。 生成器是如何利用噪音生成图片的? 我们希望生成的图片可以看作在空间中按照一定概率密度Pd(x)分布的高维张量。 注意这个概率分布不能简单的理解为X∈(长,宽,通道),y∈[0,1]的一个概率分布,我们学习到的是一种更为高维与复杂的分布,它至少包含了一部分像素之间的关系(因为用到了超过1*1的卷积核)。 如果用能够用概率函数Pg(x)拟合出这个高维分布,就能够利用噪音生成所需图片,至于如何拟合有两种思路。 一是自编码器(Auto Encoder)和变分编码器(VAE)的思路,个人认为这种思路的本质就是在做极大似然拟合,也就是说,通过采样,让样本点出现概率最大来调整参数,最终对真正分布进行拟合。李宏毅讲,因为只是根据pd(x)与pg(x)之间的距离进行调整,所以这种做法的问题是生成器比较死板,即使是距离相同的分布,可能实际效果是大不相同的。 二是对抗生成神经网络

Keras_dcgan生成自己的数据

时光总嘲笑我的痴心妄想 提交于 2019-12-05 09:54:55
from __future__ import print_function, division from keras.datasets import mnist from keras.layers import Input, Dense, Reshape, Flatten, Dropout from keras.layers import BatchNormalization, Activation, ZeroPadding2D from keras.layers.advanced_activations import LeakyReLU from keras.layers.convolutional import UpSampling2D, Conv2D from keras.models import Sequential, Model from keras.optimizers import Adam import os import matplotlib.pyplot as plt import sys import numpy as np class DCGAN(): def __init__(self): # Input shape self.img_rows = 4 self.img_cols = 60 self.channels = 1 self.img_shape

pytorch:DCGAN生成动漫头像

淺唱寂寞╮ 提交于 2019-12-05 09:49:39
动漫头像数据集下载地址: 动漫头像数据集_百度云连接 ,DCGAN论文下载地址: https://arxiv.org/abs/1511.06434 数据集里面的图片是这个样子的: 这是DCGAN的主要改进地方: 下面是所有代码: 第一个模块: import torch import torch.nn as nn import numpy as np import torch.nn.init as init import data_helper from torchvision import transforms trans = transforms.Compose( [ transforms.ToTensor(), transforms.Normalize((.5, .5, .5), (.5, .5, .5)) ] ) G_LR = 0.0002 D_LR = 0.0002 BATCHSIZE = 50 EPOCHES = 3000 def init_ws_bs(m): if isinstance(m, nn.ConvTranspose2d): init.normal_(m.weight.data, std=0.2) init.normal_(m.bias.data, std=0.2) class Generator(nn.Module): def __init__(self):

Alexnet

 ̄綄美尐妖づ 提交于 2019-12-05 09:43:55
""" AlexNet Keras implementation """ # Import necessary libs import os from keras.models import Model from keras.layers import Conv2D, MaxPool2D, ZeroPadding2D, Dense, Dropout, \ Activation, Flatten, BatchNormalization, Input from keras.regularizers import l2 from keras.preprocessing.image import ImageDataGenerator from keras.utils import multi_gpu_model from keras.callbacks import TensorBoard, EarlyStopping import math os.environ[ "CUDA_VISIBLE_DEVICES "] = "2, 3 " def AlexNet( input_shape =( 224, 224, 3), num_classes = 10, l2_reg = 0.0, weights = None): """ AlexNet model :param input_shape:

Libgdx Scene2d - Set actor ( TextField ) padding?

烈酒焚心 提交于 2019-12-05 09:38:01
i have been having trouble setting padding or something similar to an actor. Cant figure out the way. I guess that I must add something in the skin maybe? I have this TextField: textboxskin = new Skin(); textboxskin.add("textfieldback", new Texture("data/textfieldback.png")); textboxskin.add("cursor", new Texture("data/cursortextfield.png")); textboxskin.add("selection", new Texture("data/selection.png")); textboxskin.add("font", font); TextFieldStyle textfieldstyle = new TextFieldStyle(); textfieldstyle.background= textboxskin.getDrawable("textfieldback"); textfieldstyle.disabledFontColor

PyTorch版本DCGAN实现的注解

纵然是瞬间 提交于 2019-12-05 09:35:00
PyTorch版本DCGAN实现的注解 该篇博文是对 PyTorch 官方 Examples 中 DCGAN (Deep Convolution Generative Adversarial Networks)实现过程中的一些细节要点的注解 首先是对该脚本运行参数的一些说明: —dataset 指定训练数据集 —dataroot 指定数据集下载路径或者已经存在的数据集路径 —workers DataLoader进行数据预处理及数据加载使用进程数 —batchSize 一次batch进入模型的图片数目 —imageSize 原始图片重采样进入模型前的大小 —nz 初始噪音向量的大小(Size of latent z z //--> vector) —ngf 生成网络中基础feature数目(随着网络层数增加,feature数目翻倍) —ndf 判别网络中基础feature数目 (随着网络层数增加,feature数据翻倍) —niter 网络训练过程中epoch数目 —lr 初始学习率 —beta1 使用Adam优化算法中的 β 1 β 1 //--> 参数值 —cuda 指定使用GPU进行训练 —netG 指定生成网络的检查点文件(保存的生成网络的权值文件) —netD 指定判别网络的检查点文件(保存的判别网络的权值文件) —outf 模型输出图片以及检查点文件的保存路径