conda
# CPU
conda create -n tensorflow_env tensorflow
conda create -n tensorflow_gpuenv tensorflow-gpu
# CPU && GPU
conda create -n tensorflow_gpuenv tensorflow-gpu
conda activate tensorflow_gpuenv
python
# CPU
pip install --upgrade tensorflow
# CPU && GPU
pip install --upgrade tensorflow-gpu
check
import tensorflow as tf
hello = tf.constant("Hello TensorFlow")
tf.print(hello)
卷积
#stride 为卷积步长
nn.Conv2d(in_channels, out_channels, kernel_size=2, stride=1)
nn.Conv2d(in_channels, out_channels, kernel_size=2, stride=2)
nn.Conv2d(in_channels, out_channels, kernel_size=2, stride=2,
padding=2)
转置卷积
#stride 为原始输入步长
nn.ConvTranspose2d(in_channels, out_channels, kernel_size=2, stride=2)
nn.ConvTranspose2d(in_channels, out_channels, kernel_size=2, stride=1)