91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 12.32MB
    文件類型: .zip
    金幣: 1
    下載: 0 次
    發布日期: 2023-07-25
  • 語言: 其他
  • 標簽: autoencoder??CNN??

資源簡介

tensorflow下構建三層卷積層,三層反卷積層實現卷積自編碼,針對系數為0.5的高斯噪聲亦有較好效果,可通過tensorboard查看輸入輸出圖像

資源截圖

代碼片段和文件信息

from?tensorflow.examples.tutorials.mnist?import?input_data
import?tensorflow?as?tf
import?numpy?as?np
import?utils
mnist?=?input_data.read_data_sets(“MNIST_data/“?one_hot=True)
sess?=?tf.InteractiveSession()
batch_size?=?256
noise_scale?=?0.5
def?weights_variable(shape):
????initial?=?tf.truncated_normal(shape?stddev=0.1)
????return?tf.Variable(initial)

def?bias_variable(shape):
????initial?=?tf.constant(0.1?shape=shape)
????return??tf.Variable(initial)

#strides?第一個參數:batch上的步長,第二個:height上的步長,第三個:weights上的步長,第四個:channel上的步長
def?conv2d(x?W):
????return?tf.nn.conv2d(x?W?strides=[1?1?1?1]?padding=‘SAME‘)

def?deconv2d(x?W?output):
????return?tf.nn.conv2d_transpose(x?W?output?strides=[1?2?2?1]?padding=‘SAME‘)
#ksize?第一個參數:batch上的池化,第二個:height上的池化,第三個:weights上的池化,第四個:channel上的池化
def?max_pool_2x2(x):
????return?tf.nn.max_pool(x?ksize=[1?2?2?1]?strides=[1?2?2?1]?padding=‘SAME‘)


x?=?tf.placeholder(tf.float32?[None?784]?name=‘input‘)
x_noise?=?tf.placeholder(tf.float32?[None?784]?name=‘input‘)
#y_?=?tf.placeholder(tf.float32?[None?10])
#-1代表樣本數量不固定,最后的1代表顏色通道數量
x_image?=?tf.reshape(x?[-1?28?28?1])
x_image_noise?=?tf.reshape(x_noise?[-1?28?28?1])
#編碼
W_conv1?=?weights_variable([3?3?1?64])
b_conv1?=?bias_variable([64])
h_conv1?=?tf.nn.relu(conv2d(x_image_noise?W_conv1)?+?b_conv1?name=‘noise_layer‘)
h_pool1?=?max_pool_2x2(h_conv1)
W_conv2?=?weights_variable([3?3?64?64])
b_conv2?=?bias_variable([64])
h_conv2?=?tf.nn.relu(conv2d(h_pool1?W_conv2)?+?b_conv2)
h_pool2?=?max_pool_2x2(h_conv2)
W_conv3?=?weights_variable([3?3?64?32])
b_conv3?=?bias_variable([32])
h_conv3?=?tf.nn.relu(conv2d(h_pool2?W_conv3)?+?b_conv3)
h_pool3?=?max_pool_2x2(h_conv3)
#解碼
W_deconv1?=?weights_variable([3?3?32?32])
h_deconv1?=?deconv2d(h_pool3?W_deconv1?[batch_size?7?7?32])
W_deconv2?=?weights_variable([3?3?64?32])
h_deconv2?=?deconv2d(h_deconv1?W_deconv2?[batch_size?14?14?64])
W_deconv3?=?weights_variable([3?3?64?64])
h_deconv3?=?deconv2d(h_deconv2?W_deconv3?[batch_size?28?28?64])
#卷積層
W_conv_final?=?weights_variable([3?3?64?1])
b_conv_final?=?bias_variable([1])
h_conv_final?=?tf.nn.bias_add(conv2d(h_deconv3?W_conv_final)?b_conv_final?name=‘output_layer‘)

#輸出圖像

output_img?=?tf.reshape(h_conv_final?shape=[-1?28?28?1])
output_img_fomat?=?utils.convert2int(output_img)
output?=?tf.reshape(h_conv_final?shape=[-1?784])
input?=?tf.reshape(x?shape=[-1?784])
#訓練
cost?=?tf.reduce_mean(tf.pow(tf.subtract(output?input)?2.0))?#計算平方誤差
train_steps?=?tf.train.AdamOptimizer(0.001).minimize(cost)
with?tf.name_scope(‘images‘):
????tf.summary.image(‘input‘?x_image?1)
????tf.summary.image(‘gaussian‘?x_image_noise?1)
????tf.summary.image(‘reconstruction‘?(output_img_fomat)?1)

merged?=?tf.summary.merge_all()

n_samples?=?int(mnist.train.num_examples)
print(‘train?samples:?%d‘?%?n_samples)
print(‘batch?size:?%d‘?%?batch_size)

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2018-11-30?15:36??6_ConvAutoEncoder\
?????文件????????4245??2018-11-17?15:56??6_ConvAutoEncoder\6.py
?????目錄???????????0??2018-11-15?19:45??6_ConvAutoEncoder\MNIST_data\
?????文件?????1648877??2018-11-15?19:45??6_ConvAutoEncoder\MNIST_data\t10k-images-idx3-ubyte.gz
?????文件????????4542??2018-11-15?19:45??6_ConvAutoEncoder\MNIST_data\t10k-labels-idx1-ubyte.gz
?????文件?????9912422??2018-11-15?19:45??6_ConvAutoEncoder\MNIST_data\train-images-idx3-ubyte.gz
?????文件???????28881??2018-11-15?19:45??6_ConvAutoEncoder\MNIST_data\train-labels-idx1-ubyte.gz
?????目錄???????????0??2018-11-17?15:49??6_ConvAutoEncoder\__pycache__\
?????文件????????2219??2018-11-17?15:49??6_ConvAutoEncoder\__pycache__\utils.cpython-36.pyc
?????目錄???????????0??2018-11-17?16:03??6_ConvAutoEncoder\checkpoint_dir\
?????文件?????1453460??2018-11-17?16:03??6_ConvAutoEncoder\checkpoint_dir\CAEmodel.data-00000-of-00001
?????文件????????1290??2018-11-17?16:03??6_ConvAutoEncoder\checkpoint_dir\CAEmodel.index
?????文件???????84899??2018-11-17?16:03??6_ConvAutoEncoder\checkpoint_dir\CAEmodel.meta
?????文件??????????73??2018-11-17?16:03??6_ConvAutoEncoder\checkpoint_dir\checkpoint
?????目錄???????????0??2018-11-15?20:17??6_ConvAutoEncoder\logs\
?????目錄???????????0??2018-11-15?20:17??6_ConvAutoEncoder\logs\mnist_with_summaries\
?????目錄???????????0??2018-11-30?15:39??6_ConvAutoEncoder\logs\mnist_with_summaries\test\
?????目錄???????????0??2018-11-30?15:39??6_ConvAutoEncoder\pred\
?????文件????????1735??2018-11-17?15:49??6_ConvAutoEncoder\utils.py

評論

共有 條評論