# 深度学习算法(第26期)----深度网络中的自编码器

#### 有效的数据表示

```• 40, 27, 25, 36, 81, 57, 10, 73, 19, 68
• 50, 25, 76, 38, 19, 58, 29, 88, 44, 22, 11, 34, 17, 52, 26, 13, 40, 20
```

#### 用不完整的线性编码器实现PCA

```import tensorflow as tf
from tensorflow.contrib.layers import fully_connected
n_inputs = 3 # 3D inputs
n_hidden = 2 # 2D codings
n_outputs = n_inputs

learning_rate = 0.01

X = tf.placeholder(tf.float32, shape=[None, n_inputs])
hidden = fully_connected(X, n_hidden, activation_fn=None)
outputs = fully_connected(hidden, n_outputs, activation_fn=None)

reconstruction_loss = tf.reduce_mean(tf.square(outputs - X)) # MSE

training_op = optimizer.minimize(reconstruction_loss)

init = tf.global_variables_initializer()
```

1. 神经元的输入数量和输出数量一致。
2. 为了实现PCA，这里设置activation_fn=None，并且损失函数为MSE。

```X_train, X_test = [...] # load the dataset

n_iterations = 1000
codings = hidden # the output of the hidden layer provides the codings

with tf.Session() as sess:
init.run()
for iteration in range(n_iterations):
training_op.run(feed_dict={X: X_train}) # no labels (unsupervised)
codings_val = codings.eval(feed_dict={X: X_test})
```

355 篇文章74 人订阅

0 条评论

## 相关文章

12530

22420

16340

### 大牛书单 | 人工智能方向好书分享（第二期）

? 导语：读书是一生的功课，技术人通过读书实现自我提升，学习优秀知识沉淀。腾讯TEG读书会本期特邀腾讯AI Lab语音识别中心副总监苏丹、腾讯AI医疗中心病理...

15620

17630

9620

9020

16740

15630

12340