自编码网络(三)—— 使用去噪自编码提取MNIST特征

本文介绍了如何使用去噪自编码网络在MNIST数据集上训练模型,通过添加高斯噪声和Salt and Pepper噪声来测试模型的鲁棒性。经过训练,模型能有效地去除输入图像中的噪声,保持原始图像的特征。
摘要由CSDN通过智能技术生成

1.引入头文件,创建网络模型及定义学习参数的变量

import  numpy as np
import  tensorflow as tf
import  matplotlib.pyplot as plt
from tensorflow.examples.tutorials.mnist import input_data

mnist = input_data.read_data_sets("/data/", one_hot=True)

train_X = mnist.train.images
train_Y = mnist.train.labels
test_X  = mnist.test.images
test_Y  = mnist.test.labels

n_input = 784
n_hidden_1 = 256

#占位符
x = tf.placeholder("float", [None, n_input])
y = tf.placeholder("float", [None, n_input])
dropout_keep_prob = tf.placeholder("float")

#学习参数
weights = {'h1':tf.Variable(tf.random_normal([n_input, n_hidden_1])),
           'h2':tf.Variable(tf.random_normal([n_hidden_1, n_hidden_1])),
           'out':tf.Variable(tf.random_normal([n_hidden_1, n_input]))}

biases = {'b1':tf.Variable(tf.zeros([n_hidden_1])),
          'b2':
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值