其他分享
首页 > 其他分享> > 卷积神经网络

卷积神经网络

作者:互联网

目录

2D Convolution

35-卷积神经网络-2d卷积.jpg

Kernel size

35-卷积神经网络-卷积静态.jpg

35-卷积神经网络-卷积动态图.gif

Padding & Stride

35-卷积神经网络-卷积padding.gif

35-卷积神经网络-卷积步长2.jpg

Channels

35-卷积神经网络-通道.jpg

For instance

35-卷积神经网络-卷积张量动态.gif

LeNet-5

35-卷积神经网络-最早的神经网络.jpg

Pyramid Architecture

35-卷积神经网络-金字塔结构.jpg

layers.Conv2D

import tensorflow as tf
from tensorflow.keras import layers
x = tf.random.normal([1, 32, 32, 3])
# padding='valid':输入和输出维度不同
layer = layers.Conv2D(4, kernel_size=5, strides=1, padding='valid')
out = layer(x)
out.shape
TensorShape([1, 28, 28, 4])
# padding='same':输入和输出维度相同
layer = layers.Conv2D(4, kernel_size=5, strides=1, padding='same')
out = layer(x)
out.shape
TensorShape([1, 32, 32, 4])
layer = layers.Conv2D(4, kernel_size=5, strides=2, padding='same')
out = layer(x)
out.shape
TensorShape([1, 16, 16, 4])
layer.call(x).shape
TensorShape([1, 16, 16, 4])

weight & bias

layer = layers.Conv2D(4, kernel_size=5, strides=2, padding='same')
out = layer(x)
out.shape
TensorShape([1, 16, 16, 4])
# 5,5--》size,3--》通道数,4--》核数量
layer.kernel.shape
TensorShape([5, 5, 3, 4])
layer.bias
<tf.Variable 'conv2d_11/bias:0' shape=(4,) dtype=float32, numpy=array([0., 0., 0., 0.], dtype=float32)>

nn.conv2d

w = tf.random.normal([5, 5, 3, 4])
b = tf.zeros([4])
x.shape
TensorShape([1, 32, 32, 3])
out = tf.nn.conv2d(x, w, strides=1, padding='VALID')
out.shape
TensorShape([1, 28, 28, 4])
out = out + b
out.shape
TensorShape([1, 28, 28, 4])
out = tf.nn.conv2d(x, w, strides=2, padding='VALID')
out.shape
TensorShape([1, 14, 14, 4])

Gradient?

Lossw

35-卷积神经网络-梯度.jpg

For instance

35-卷积神经网络-梯度实例.jpg

标签:layer,卷积,28,shape,padding,神经网络,TensorShape,out
来源: https://www.cnblogs.com/abdm-989/p/14123375.html