一、Deeplearning-assignment
在本节的学习中,我们将学习神经风格迁移(Neural Style Transfer)算法,通过该算法使得两张不同风格的图片融合成一张图片。
问题描述:神经风格迁移算法是深度学习中的一种有趣的技术。正如下面的图片所示,算法将两种图片的风格特点融合在了一起。
神经风格迁移:运用了一个预训练的卷积神经网络,这种将一个任务的特点运用到另一个任务的想法叫做迁移学习。
建立NST的三个步骤:
计算content的损失:
计算style的损失:
style矩阵:
定义整体的损失,并优化:
创建一个函数,用来使content损失和style损失最小化:
神经风格迁移算法总体流程:
- Create an Interactive Session
- Load the content image
- Load the style image
- Randomly initialize the image to be generated
- Load the VGG16 model
- Build the TensorFlow graph:
- Run the content image through the VGG16 model and compute the content cost
- Run the style image through the VGG16 model and compute the style cost
- Compute the total cost
- Define the optimizer and the learning rate
- Initialize the