Tensorflow tf.layers

222 阅读1分钟
import tensorflow as tf
/anaconda3/envs/py35/lib/python3.5/site-packages/h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
  from ._conv import register_converters as _register_converters
inputs = tf.placeholder(tf.float32, [None, 10])
output = tf.layers.dense(inputs, 1)
output.get_shape()
TensorShape([Dimension(None), Dimension(1)])
inputs = tf.placeholder(tf.float32, [None, 32, 32, 3])
output = tf.layers.conv2d(inputs, 64, 5)
output.get_shape()
TensorShape([Dimension(None), Dimension(28), Dimension(28), Dimension(64)])
output = tf.layers.conv2d(inputs, 64, 5, strides=(2,2), padding='same')
output.get_shape()
TensorShape([Dimension(None), Dimension(16), Dimension(16), Dimension(64)])
out2 = tf.layers.max_pooling2d(output, 2, 2)
out2.get_shape()
TensorShape([Dimension(None), Dimension(8), Dimension(8), Dimension(64)])