-
大小: 4KB文件类型: .py金币: 1下载: 0 次发布日期: 2021-05-12
- 语言: Python
- 标签: autoencoder 自编码器 tensorflow 机器学习 深度学习
资源简介
tensorflow实现的自编码器,带有详细注释,使用MNIST作为数据集,安装好python及tensorflow即可运行
代码片段和文件信息
# -*- coding: utf-8 -*-
from __future__ import division print_function absolute_import
import tensorflow as tf
import numpy as np
import matplotlib.pyplot as plt
# Import MNIST data
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets(“MNIST_data“ one_hot=True)
# Parameters
learning_rate = 0.01
training_epochs = 20
batch_size = 256
display_step = 1
examples_to_show = 10
# Network Parameters
n_hidden_1 = 256 # 1st layer num features
n_hidden_2 = 128 # 2nd layer num features
n_input = 784 # MNIST data input (img shape: 28*28)
# tf Graph input (only pictures)
X = tf.placeholder(“float“ [None n_input])
weights = {
‘encoder_h1‘: tf.Variable(tf.random_normal([n_input n_hidden_1]))
‘encoder_h2‘: tf.Variable(tf.random_normal([n_hidden_1 n_hidden_2]))
‘decoder_h1‘: tf.Variable(tf.random_normal([n_hidden_2 n_hidden_1]))
‘decoder_h2‘: tf.Variable(tf.random_normal([n_hidden_1 n_input]))
}
biases = {
‘encoder_b1‘: tf.Variable(tf.random_normal([n_hidden_1]))
‘encoder_b2‘: tf.Variable(tf.random_normal([n_hidden_2]))
‘decoder_b1‘: tf.Variable(tf.random_normal([n_hidden_1]))
‘decoder_b2‘: tf.Variable(tf.random_normal([n_input]))
}
# Building the encoder
def encoder(x):
# Encoder Hidden layer with sigmoid activation #1
layer_1 = tf.nn.sigmoid(tf.add(tf.matmul(x weights[‘encoder_h1‘])
biases[‘encoder_b1‘]))
# Decoder Hidden layer with sigmoid activation #2
layer_2 = tf.nn.sigmoid(tf.add(tf.matmul(layer_1 weights[‘encoder_h2‘])
biases[‘encoder_b2‘]))
return layer_2
# Building the decoder
def decoder(x):
# Encoder Hidden layer with sigmoid activation #1
layer_1 = tf.nn.sigmoid(tf.add(tf.matmul(x weights[‘decoder_h1‘])
- 上一篇:CNN卷积神经网络TensorFlow代码
- 下一篇:神经网络模型python模板
相关资源
- DeepLabV3-Tensorflow-master
- 基于TensorFlow实现CNN文本分类实验指导
- tensorflow2.0 yolo3目标检测算法
- tensorflow制作自己的灰度图像数据集并
- anaconda下安装tensorflow(注:不同版本
- 北京大学曹健老师-人工智能实践:
- Deep Learning With Python - Jason Brownlee
- Python-自然场景文本检测PSENet的一个
- Python-高效准确的EAST文本检测器的一个
- Python-TensorFlow弱监督图像分割
- Python-基于tensorflow实现的用textcnn方法
- Python-subpixel利用Tensorflow的一个子像素
- 【官方文档】TensorFlow Python API docume
-
tensorflow画风迁移代码 st
yle transfer - 简单粗暴 TensorFlow
- [PDF] Reinforcement Learning With Open AI Tens
- tensorflow目标检测代码
- 基于Python的手写字体识别系统
- 基于Tensorflow的人脸识别源码
- python TensorFlow 官方文档中文版
- Python-在TensorFlow中实现实现图像卷积网
- tensorflow-1.9.0-cp37-cp37m-win_amd64.whl
- Faster-RCNN-TensorFlow-Python3.5-master
- 聊天机器人tensorflow
- caffe模型转化为tensorflow模型
- Python-一个非常简单的BiLSTMCRF模型用于
- Python-Tensorflow仿AlphaGo框架实现的AI围棋
- Mask R-CNN源码(TensorFlow版本)
- 基于python3 tensorflow DBN_and_RNN的实现
- tensorflow-0.8.0-cp34-cp34m-linux_x86_64.whl
评论
共有 条评论