资源简介
gan代码,可以用于深度学习的学习,是很好用的代码,现分享出来.
代码片段和文件信息
clc
clear
%% 构造真实训练样本 60000个样本 1*784维(28*28展开)
load mnist_uint8;
train_x = double(train_x(1:60000:)) / 255;
% 真实样本认为为标签 [1 0]; 生成样本为[0 1];
train_y = double(ones(size(train_x1)1));
% normalize
train_x = mapminmax(train_x 0 1);
rand(‘state‘0)
%% 构造模拟训练样本 60000个样本 1*100维
test_x = normrnd(01[60000100]); % 0-255的整数
test_x = mapminmax(test_x 0 1);
test_y = double(zeros(size(test_x1)1));
test_y_rel = double(ones(size(test_x1)1));
%%
nn_G_t = nnsetup([100 784]);
nn_G_t.activation_function = ‘sigm‘;
nn_G_t.output = ‘sigm‘;
nn_D = nnsetup([784 100 1]);
nn_D.weightPenaltyL2 = 1e-4; % L2 weight decay
nn.dropoutFraction = 0.5; % Dropout fraction
nn.learningRate = 0.01; % Sigm require a lower learning rate
nn_D.activation_function = ‘sigm‘;
nn_D.output = ‘sigm‘;
% nn_D.weightPenaltyL2 = 1e-4; % L2 weight decay
nn_G = nnsetup([100 784 100 1]);
nn_D.weightPenaltyL2 = 1e-4; % L2 weight decay
nn.dropoutFraction = 0.5; % Dropout fraction
nn.learningRate = 0.01; % Sigm require a lower learning rate
nn_G.activation_function = ‘
评论
共有 条评论