IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> 人工智能 -> TensorFlow 从入门到精通(11)—— DeepDream(上) -> 正文阅读

[人工智能]TensorFlow 从入门到精通(11)—— DeepDream(上)

这节课,我翘了两天,原因是最近压力比较大。
大家可能对卷积云里雾里,这节课我们就可视化一下卷积层。通过噪声图像起点单层网络单通道/单层网络多通道/多层网络全通道 来生成几幅图像,让大家看一下卷积神经网络中某一个层的输出,通过与原图像的对比,可以看到卷积层对图像的影响。
另外,这是上,下一个我们将这个有趣的项目应用到图片中,生成一些比较魔性的图片。
选择了远方,就走下去吧!!
下一个是本项目的下一篇

  • 必看:

  • 本项目并不训练模型,而是“训练”图像的像素值

  • Deep Dream项目是Google在2015年公布的一个十分有趣的项目,在训练好的神经网络中,只需要修改几个参数就可以通过这项技术生成一张奇幻的图像。

在固定的模型上,通过不断修改图像的像素值不断改变输入,激活某一层(让其损失最大)

import tensorflow as tf
tf.__version__
'2.6.0'
# 检测是否支持GPU
tf.test.is_gpu_available()
True
  • 安装pillow库
    pip install pillow
import numpy as np
import IPython.display as display
import PIL.Image
from tensorflow.keras.preprocessing import image

一、定义相关函数

# 图像标准化
def normalize_image(img):
  img = 255 * (img + 1.0) / 2.0
  return tf.cast(img,tf.uint8)
# 图像可视化
import matplotlib.pyplot as plt

def show_image(img):
  display.display(PIL.Image.fromarray(np.array(img)))
  # plt.imshow(np.array(img))
# 保存图像文件
def save_image(img,file_name):
  PIL.Image.fromarray(np.array(img)).save(file_name)

二、产生噪音起点图像文件(相当于数据集)

img_noise = np.random.uniform(size=(300,300,3)) + 100.0 # 这里加100的作用是为了提高图像的亮度
img_noise = img_noise.astype(np.float32) # dtypy转换成float32
show_image(normalize_image(img_noise))

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-qBdJ565o-1633621084682)(output_10_0.png)]

三、构建模型

  • 导入imagenet数据集的图像识别预训练InceptionV3模型
  • 去掉顶层,这样能接受新的训练数据shape

1.加载预训练模型

base_model = tf.keras.applications.InceptionV3(include_top=False,weights='imagenet')
base_model.summary()
Model: "inception_v3"
__________________________________________________________________________________________________
Layer (type)                    Output Shape         Param #     Connected to                     
==================================================================================================
input_7 (InputLayer)            [(None, None, None,  0                                            
__________________________________________________________________________________________________
conv2d_564 (Conv2D)             (None, None, None, 3 864         input_7[0][0]                    
__________________________________________________________________________________________________
batch_normalization_564 (BatchN (None, None, None, 3 96          conv2d_564[0][0]                 
__________________________________________________________________________________________________
activation_564 (Activation)     (None, None, None, 3 0           batch_normalization_564[0][0]    
__________________________________________________________________________________________________
conv2d_565 (Conv2D)             (None, None, None, 3 9216        activation_564[0][0]             
__________________________________________________________________________________________________
batch_normalization_565 (BatchN (None, None, None, 3 96          conv2d_565[0][0]                 
__________________________________________________________________________________________________
activation_565 (Activation)     (None, None, None, 3 0           batch_normalization_565[0][0]    
__________________________________________________________________________________________________
conv2d_566 (Conv2D)             (None, None, None, 6 18432       activation_565[0][0]             
__________________________________________________________________________________________________
batch_normalization_566 (BatchN (None, None, None, 6 192         conv2d_566[0][0]                 
__________________________________________________________________________________________________
activation_566 (Activation)     (None, None, None, 6 0           batch_normalization_566[0][0]    
__________________________________________________________________________________________________
max_pooling2d_24 (MaxPooling2D) (None, None, None, 6 0           activation_566[0][0]             
__________________________________________________________________________________________________
conv2d_567 (Conv2D)             (None, None, None, 8 5120        max_pooling2d_24[0][0]           
__________________________________________________________________________________________________
batch_normalization_567 (BatchN (None, None, None, 8 240         conv2d_567[0][0]                 
__________________________________________________________________________________________________
activation_567 (Activation)     (None, None, None, 8 0           batch_normalization_567[0][0]    
__________________________________________________________________________________________________
conv2d_568 (Conv2D)             (None, None, None, 1 138240      activation_567[0][0]             
__________________________________________________________________________________________________
batch_normalization_568 (BatchN (None, None, None, 1 576         conv2d_568[0][0]                 
__________________________________________________________________________________________________
activation_568 (Activation)     (None, None, None, 1 0           batch_normalization_568[0][0]    
__________________________________________________________________________________________________
max_pooling2d_25 (MaxPooling2D) (None, None, None, 1 0           activation_568[0][0]             
__________________________________________________________________________________________________
conv2d_572 (Conv2D)             (None, None, None, 6 12288       max_pooling2d_25[0][0]           
__________________________________________________________________________________________________
batch_normalization_572 (BatchN (None, None, None, 6 192         conv2d_572[0][0]                 
__________________________________________________________________________________________________
activation_572 (Activation)     (None, None, None, 6 0           batch_normalization_572[0][0]    
__________________________________________________________________________________________________
conv2d_570 (Conv2D)             (None, None, None, 4 9216        max_pooling2d_25[0][0]           
__________________________________________________________________________________________________
conv2d_573 (Conv2D)             (None, None, None, 9 55296       activation_572[0][0]             
__________________________________________________________________________________________________
batch_normalization_570 (BatchN (None, None, None, 4 144         conv2d_570[0][0]                 
__________________________________________________________________________________________________
batch_normalization_573 (BatchN (None, None, None, 9 288         conv2d_573[0][0]                 
__________________________________________________________________________________________________
activation_570 (Activation)     (None, None, None, 4 0           batch_normalization_570[0][0]    
__________________________________________________________________________________________________
activation_573 (Activation)     (None, None, None, 9 0           batch_normalization_573[0][0]    
__________________________________________________________________________________________________
average_pooling2d_54 (AveragePo (None, None, None, 1 0           max_pooling2d_25[0][0]           
__________________________________________________________________________________________________
conv2d_569 (Conv2D)             (None, None, None, 6 12288       max_pooling2d_25[0][0]           
__________________________________________________________________________________________________
conv2d_571 (Conv2D)             (None, None, None, 6 76800       activation_570[0][0]             
__________________________________________________________________________________________________
conv2d_574 (Conv2D)             (None, None, None, 9 82944       activation_573[0][0]             
__________________________________________________________________________________________________
conv2d_575 (Conv2D)             (None, None, None, 3 6144        average_pooling2d_54[0][0]       
__________________________________________________________________________________________________
batch_normalization_569 (BatchN (None, None, None, 6 192         conv2d_569[0][0]                 
__________________________________________________________________________________________________
batch_normalization_571 (BatchN (None, None, None, 6 192         conv2d_571[0][0]                 
__________________________________________________________________________________________________
batch_normalization_574 (BatchN (None, None, None, 9 288         conv2d_574[0][0]                 
__________________________________________________________________________________________________
batch_normalization_575 (BatchN (None, None, None, 3 96          conv2d_575[0][0]                 
__________________________________________________________________________________________________
activation_569 (Activation)     (None, None, None, 6 0           batch_normalization_569[0][0]    
__________________________________________________________________________________________________
activation_571 (Activation)     (None, None, None, 6 0           batch_normalization_571[0][0]    
__________________________________________________________________________________________________
activation_574 (Activation)     (None, None, None, 9 0           batch_normalization_574[0][0]    
__________________________________________________________________________________________________
activation_575 (Activation)     (None, None, None, 3 0           batch_normalization_575[0][0]    
__________________________________________________________________________________________________
mixed0 (Concatenate)            (None, None, None, 2 0           activation_569[0][0]             
                                                                 activation_571[0][0]             
                                                                 activation_574[0][0]             
                                                                 activation_575[0][0]             
__________________________________________________________________________________________________
conv2d_579 (Conv2D)             (None, None, None, 6 16384       mixed0[0][0]                     
__________________________________________________________________________________________________
batch_normalization_579 (BatchN (None, None, None, 6 192         conv2d_579[0][0]                 
__________________________________________________________________________________________________
activation_579 (Activation)     (None, None, None, 6 0           batch_normalization_579[0][0]    
__________________________________________________________________________________________________
conv2d_577 (Conv2D)             (None, None, None, 4 12288       mixed0[0][0]                     
__________________________________________________________________________________________________
conv2d_580 (Conv2D)             (None, None, None, 9 55296       activation_579[0][0]             
__________________________________________________________________________________________________
batch_normalization_577 (BatchN (None, None, None, 4 144         conv2d_577[0][0]                 
__________________________________________________________________________________________________
batch_normalization_580 (BatchN (None, None, None, 9 288         conv2d_580[0][0]                 
__________________________________________________________________________________________________
activation_577 (Activation)     (None, None, None, 4 0           batch_normalization_577[0][0]    
__________________________________________________________________________________________________
activation_580 (Activation)     (None, None, None, 9 0           batch_normalization_580[0][0]    
__________________________________________________________________________________________________
average_pooling2d_55 (AveragePo (None, None, None, 2 0           mixed0[0][0]                     
__________________________________________________________________________________________________
conv2d_576 (Conv2D)             (None, None, None, 6 16384       mixed0[0][0]                     
__________________________________________________________________________________________________
conv2d_578 (Conv2D)             (None, None, None, 6 76800       activation_577[0][0]             
__________________________________________________________________________________________________
conv2d_581 (Conv2D)             (None, None, None, 9 82944       activation_580[0][0]             
__________________________________________________________________________________________________
conv2d_582 (Conv2D)             (None, None, None, 6 16384       average_pooling2d_55[0][0]       
__________________________________________________________________________________________________
batch_normalization_576 (BatchN (None, None, None, 6 192         conv2d_576[0][0]                 
__________________________________________________________________________________________________
batch_normalization_578 (BatchN (None, None, None, 6 192         conv2d_578[0][0]                 
__________________________________________________________________________________________________
batch_normalization_581 (BatchN (None, None, None, 9 288         conv2d_581[0][0]                 
__________________________________________________________________________________________________
batch_normalization_582 (BatchN (None, None, None, 6 192         conv2d_582[0][0]                 
__________________________________________________________________________________________________
activation_576 (Activation)     (None, None, None, 6 0           batch_normalization_576[0][0]    
__________________________________________________________________________________________________
activation_578 (Activation)     (None, None, None, 6 0           batch_normalization_578[0][0]    
__________________________________________________________________________________________________
activation_581 (Activation)     (None, None, None, 9 0           batch_normalization_581[0][0]    
__________________________________________________________________________________________________
activation_582 (Activation)     (None, None, None, 6 0           batch_normalization_582[0][0]    
__________________________________________________________________________________________________
mixed1 (Concatenate)            (None, None, None, 2 0           activation_576[0][0]             
                                                                 activation_578[0][0]             
                                                                 activation_581[0][0]             
                                                                 activation_582[0][0]             
__________________________________________________________________________________________________
conv2d_586 (Conv2D)             (None, None, None, 6 18432       mixed1[0][0]                     
__________________________________________________________________________________________________
batch_normalization_586 (BatchN (None, None, None, 6 192         conv2d_586[0][0]                 
__________________________________________________________________________________________________
activation_586 (Activation)     (None, None, None, 6 0           batch_normalization_586[0][0]    
__________________________________________________________________________________________________
conv2d_584 (Conv2D)             (None, None, None, 4 13824       mixed1[0][0]                     
__________________________________________________________________________________________________
conv2d_587 (Conv2D)             (None, None, None, 9 55296       activation_586[0][0]             
__________________________________________________________________________________________________
batch_normalization_584 (BatchN (None, None, None, 4 144         conv2d_584[0][0]                 
__________________________________________________________________________________________________
batch_normalization_587 (BatchN (None, None, None, 9 288         conv2d_587[0][0]                 
__________________________________________________________________________________________________
activation_584 (Activation)     (None, None, None, 4 0           batch_normalization_584[0][0]    
__________________________________________________________________________________________________
activation_587 (Activation)     (None, None, None, 9 0           batch_normalization_587[0][0]    
__________________________________________________________________________________________________
average_pooling2d_56 (AveragePo (None, None, None, 2 0           mixed1[0][0]                     
__________________________________________________________________________________________________
conv2d_583 (Conv2D)             (None, None, None, 6 18432       mixed1[0][0]                     
__________________________________________________________________________________________________
conv2d_585 (Conv2D)             (None, None, None, 6 76800       activation_584[0][0]             
__________________________________________________________________________________________________
conv2d_588 (Conv2D)             (None, None, None, 9 82944       activation_587[0][0]             
__________________________________________________________________________________________________
conv2d_589 (Conv2D)             (None, None, None, 6 18432       average_pooling2d_56[0][0]       
__________________________________________________________________________________________________
batch_normalization_583 (BatchN (None, None, None, 6 192         conv2d_583[0][0]                 
__________________________________________________________________________________________________
batch_normalization_585 (BatchN (None, None, None, 6 192         conv2d_585[0][0]                 
__________________________________________________________________________________________________
batch_normalization_588 (BatchN (None, None, None, 9 288         conv2d_588[0][0]                 
__________________________________________________________________________________________________
batch_normalization_589 (BatchN (None, None, None, 6 192         conv2d_589[0][0]                 
__________________________________________________________________________________________________
activation_583 (Activation)     (None, None, None, 6 0           batch_normalization_583[0][0]    
__________________________________________________________________________________________________
activation_585 (Activation)     (None, None, None, 6 0           batch_normalization_585[0][0]    
__________________________________________________________________________________________________
activation_588 (Activation)     (None, None, None, 9 0           batch_normalization_588[0][0]    
__________________________________________________________________________________________________
activation_589 (Activation)     (None, None, None, 6 0           batch_normalization_589[0][0]    
__________________________________________________________________________________________________
mixed2 (Concatenate)            (None, None, None, 2 0           activation_583[0][0]             
                                                                 activation_585[0][0]             
                                                                 activation_588[0][0]             
                                                                 activation_589[0][0]             
__________________________________________________________________________________________________
conv2d_591 (Conv2D)             (None, None, None, 6 18432       mixed2[0][0]                     
__________________________________________________________________________________________________
batch_normalization_591 (BatchN (None, None, None, 6 192         conv2d_591[0][0]                 
__________________________________________________________________________________________________
activation_591 (Activation)     (None, None, None, 6 0           batch_normalization_591[0][0]    
__________________________________________________________________________________________________
conv2d_592 (Conv2D)             (None, None, None, 9 55296       activation_591[0][0]             
__________________________________________________________________________________________________
batch_normalization_592 (BatchN (None, None, None, 9 288         conv2d_592[0][0]                 
__________________________________________________________________________________________________
activation_592 (Activation)     (None, None, None, 9 0           batch_normalization_592[0][0]    
__________________________________________________________________________________________________
conv2d_590 (Conv2D)             (None, None, None, 3 995328      mixed2[0][0]                     
__________________________________________________________________________________________________
conv2d_593 (Conv2D)             (None, None, None, 9 82944       activation_592[0][0]             
__________________________________________________________________________________________________
batch_normalization_590 (BatchN (None, None, None, 3 1152        conv2d_590[0][0]                 
__________________________________________________________________________________________________
batch_normalization_593 (BatchN (None, None, None, 9 288         conv2d_593[0][0]                 
__________________________________________________________________________________________________
activation_590 (Activation)     (None, None, None, 3 0           batch_normalization_590[0][0]    
__________________________________________________________________________________________________
activation_593 (Activation)     (None, None, None, 9 0           batch_normalization_593[0][0]    
__________________________________________________________________________________________________
max_pooling2d_26 (MaxPooling2D) (None, None, None, 2 0           mixed2[0][0]                     
__________________________________________________________________________________________________
mixed3 (Concatenate)            (None, None, None, 7 0           activation_590[0][0]             
                                                                 activation_593[0][0]             
                                                                 max_pooling2d_26[0][0]           
__________________________________________________________________________________________________
conv2d_598 (Conv2D)             (None, None, None, 1 98304       mixed3[0][0]                     
__________________________________________________________________________________________________
batch_normalization_598 (BatchN (None, None, None, 1 384         conv2d_598[0][0]                 
__________________________________________________________________________________________________
activation_598 (Activation)     (None, None, None, 1 0           batch_normalization_598[0][0]    
__________________________________________________________________________________________________
conv2d_599 (Conv2D)             (None, None, None, 1 114688      activation_598[0][0]             
__________________________________________________________________________________________________
batch_normalization_599 (BatchN (None, None, None, 1 384         conv2d_599[0][0]                 
__________________________________________________________________________________________________
activation_599 (Activation)     (None, None, None, 1 0           batch_normalization_599[0][0]    
__________________________________________________________________________________________________
conv2d_595 (Conv2D)             (None, None, None, 1 98304       mixed3[0][0]                     
__________________________________________________________________________________________________
conv2d_600 (Conv2D)             (None, None, None, 1 114688      activation_599[0][0]             
__________________________________________________________________________________________________
batch_normalization_595 (BatchN (None, None, None, 1 384         conv2d_595[0][0]                 
__________________________________________________________________________________________________
batch_normalization_600 (BatchN (None, None, None, 1 384         conv2d_600[0][0]                 
__________________________________________________________________________________________________
activation_595 (Activation)     (None, None, None, 1 0           batch_normalization_595[0][0]    
__________________________________________________________________________________________________
activation_600 (Activation)     (None, None, None, 1 0           batch_normalization_600[0][0]    
__________________________________________________________________________________________________
conv2d_596 (Conv2D)             (None, None, None, 1 114688      activation_595[0][0]             
__________________________________________________________________________________________________
conv2d_601 (Conv2D)             (None, None, None, 1 114688      activation_600[0][0]             
__________________________________________________________________________________________________
batch_normalization_596 (BatchN (None, None, None, 1 384         conv2d_596[0][0]                 
__________________________________________________________________________________________________
batch_normalization_601 (BatchN (None, None, None, 1 384         conv2d_601[0][0]                 
__________________________________________________________________________________________________
activation_596 (Activation)     (None, None, None, 1 0           batch_normalization_596[0][0]    
__________________________________________________________________________________________________
activation_601 (Activation)     (None, None, None, 1 0           batch_normalization_601[0][0]    
__________________________________________________________________________________________________
average_pooling2d_57 (AveragePo (None, None, None, 7 0           mixed3[0][0]                     
__________________________________________________________________________________________________
conv2d_594 (Conv2D)             (None, None, None, 1 147456      mixed3[0][0]                     
__________________________________________________________________________________________________
conv2d_597 (Conv2D)             (None, None, None, 1 172032      activation_596[0][0]             
__________________________________________________________________________________________________
conv2d_602 (Conv2D)             (None, None, None, 1 172032      activation_601[0][0]             
__________________________________________________________________________________________________
conv2d_603 (Conv2D)             (None, None, None, 1 147456      average_pooling2d_57[0][0]       
__________________________________________________________________________________________________
batch_normalization_594 (BatchN (None, None, None, 1 576         conv2d_594[0][0]                 
__________________________________________________________________________________________________
batch_normalization_597 (BatchN (None, None, None, 1 576         conv2d_597[0][0]                 
__________________________________________________________________________________________________
batch_normalization_602 (BatchN (None, None, None, 1 576         conv2d_602[0][0]                 
__________________________________________________________________________________________________
batch_normalization_603 (BatchN (None, None, None, 1 576         conv2d_603[0][0]                 
__________________________________________________________________________________________________
activation_594 (Activation)     (None, None, None, 1 0           batch_normalization_594[0][0]    
__________________________________________________________________________________________________
activation_597 (Activation)     (None, None, None, 1 0           batch_normalization_597[0][0]    
__________________________________________________________________________________________________
activation_602 (Activation)     (None, None, None, 1 0           batch_normalization_602[0][0]    
__________________________________________________________________________________________________
activation_603 (Activation)     (None, None, None, 1 0           batch_normalization_603[0][0]    
__________________________________________________________________________________________________
mixed4 (Concatenate)            (None, None, None, 7 0           activation_594[0][0]             
                                                                 activation_597[0][0]             
                                                                 activation_602[0][0]             
                                                                 activation_603[0][0]             
__________________________________________________________________________________________________
conv2d_608 (Conv2D)             (None, None, None, 1 122880      mixed4[0][0]                     
__________________________________________________________________________________________________
batch_normalization_608 (BatchN (None, None, None, 1 480         conv2d_608[0][0]                 
__________________________________________________________________________________________________
activation_608 (Activation)     (None, None, None, 1 0           batch_normalization_608[0][0]    
__________________________________________________________________________________________________
conv2d_609 (Conv2D)             (None, None, None, 1 179200      activation_608[0][0]             
__________________________________________________________________________________________________
batch_normalization_609 (BatchN (None, None, None, 1 480         conv2d_609[0][0]                 
__________________________________________________________________________________________________
activation_609 (Activation)     (None, None, None, 1 0           batch_normalization_609[0][0]    
__________________________________________________________________________________________________
conv2d_605 (Conv2D)             (None, None, None, 1 122880      mixed4[0][0]                     
__________________________________________________________________________________________________
conv2d_610 (Conv2D)             (None, None, None, 1 179200      activation_609[0][0]             
__________________________________________________________________________________________________
batch_normalization_605 (BatchN (None, None, None, 1 480         conv2d_605[0][0]                 
__________________________________________________________________________________________________
batch_normalization_610 (BatchN (None, None, None, 1 480         conv2d_610[0][0]                 
__________________________________________________________________________________________________
activation_605 (Activation)     (None, None, None, 1 0           batch_normalization_605[0][0]    
__________________________________________________________________________________________________
activation_610 (Activation)     (None, None, None, 1 0           batch_normalization_610[0][0]    
__________________________________________________________________________________________________
conv2d_606 (Conv2D)             (None, None, None, 1 179200      activation_605[0][0]             
__________________________________________________________________________________________________
conv2d_611 (Conv2D)             (None, None, None, 1 179200      activation_610[0][0]             
__________________________________________________________________________________________________
batch_normalization_606 (BatchN (None, None, None, 1 480         conv2d_606[0][0]                 
__________________________________________________________________________________________________
batch_normalization_611 (BatchN (None, None, None, 1 480         conv2d_611[0][0]                 
__________________________________________________________________________________________________
activation_606 (Activation)     (None, None, None, 1 0           batch_normalization_606[0][0]    
__________________________________________________________________________________________________
activation_611 (Activation)     (None, None, None, 1 0           batch_normalization_611[0][0]    
__________________________________________________________________________________________________
average_pooling2d_58 (AveragePo (None, None, None, 7 0           mixed4[0][0]                     
__________________________________________________________________________________________________
conv2d_604 (Conv2D)             (None, None, None, 1 147456      mixed4[0][0]                     
__________________________________________________________________________________________________
conv2d_607 (Conv2D)             (None, None, None, 1 215040      activation_606[0][0]             
__________________________________________________________________________________________________
conv2d_612 (Conv2D)             (None, None, None, 1 215040      activation_611[0][0]             
__________________________________________________________________________________________________
conv2d_613 (Conv2D)             (None, None, None, 1 147456      average_pooling2d_58[0][0]       
__________________________________________________________________________________________________
batch_normalization_604 (BatchN (None, None, None, 1 576         conv2d_604[0][0]                 
__________________________________________________________________________________________________
batch_normalization_607 (BatchN (None, None, None, 1 576         conv2d_607[0][0]                 
__________________________________________________________________________________________________
batch_normalization_612 (BatchN (None, None, None, 1 576         conv2d_612[0][0]                 
__________________________________________________________________________________________________
batch_normalization_613 (BatchN (None, None, None, 1 576         conv2d_613[0][0]                 
__________________________________________________________________________________________________
activation_604 (Activation)     (None, None, None, 1 0           batch_normalization_604[0][0]    
__________________________________________________________________________________________________
activation_607 (Activation)     (None, None, None, 1 0           batch_normalization_607[0][0]    
__________________________________________________________________________________________________
activation_612 (Activation)     (None, None, None, 1 0           batch_normalization_612[0][0]    
__________________________________________________________________________________________________
activation_613 (Activation)     (None, None, None, 1 0           batch_normalization_613[0][0]    
__________________________________________________________________________________________________
mixed5 (Concatenate)            (None, None, None, 7 0           activation_604[0][0]             
                                                                 activation_607[0][0]             
                                                                 activation_612[0][0]             
                                                                 activation_613[0][0]             
__________________________________________________________________________________________________
conv2d_618 (Conv2D)             (None, None, None, 1 122880      mixed5[0][0]                     
__________________________________________________________________________________________________
batch_normalization_618 (BatchN (None, None, None, 1 480         conv2d_618[0][0]                 
__________________________________________________________________________________________________
activation_618 (Activation)     (None, None, None, 1 0           batch_normalization_618[0][0]    
__________________________________________________________________________________________________
conv2d_619 (Conv2D)             (None, None, None, 1 179200      activation_618[0][0]             
__________________________________________________________________________________________________
batch_normalization_619 (BatchN (None, None, None, 1 480         conv2d_619[0][0]                 
__________________________________________________________________________________________________
activation_619 (Activation)     (None, None, None, 1 0           batch_normalization_619[0][0]    
__________________________________________________________________________________________________
conv2d_615 (Conv2D)             (None, None, None, 1 122880      mixed5[0][0]                     
__________________________________________________________________________________________________
conv2d_620 (Conv2D)             (None, None, None, 1 179200      activation_619[0][0]             
__________________________________________________________________________________________________
batch_normalization_615 (BatchN (None, None, None, 1 480         conv2d_615[0][0]                 
__________________________________________________________________________________________________
batch_normalization_620 (BatchN (None, None, None, 1 480         conv2d_620[0][0]                 
__________________________________________________________________________________________________
activation_615 (Activation)     (None, None, None, 1 0           batch_normalization_615[0][0]    
__________________________________________________________________________________________________
activation_620 (Activation)     (None, None, None, 1 0           batch_normalization_620[0][0]    
__________________________________________________________________________________________________
conv2d_616 (Conv2D)             (None, None, None, 1 179200      activation_615[0][0]             
__________________________________________________________________________________________________
conv2d_621 (Conv2D)             (None, None, None, 1 179200      activation_620[0][0]             
__________________________________________________________________________________________________
batch_normalization_616 (BatchN (None, None, None, 1 480         conv2d_616[0][0]                 
__________________________________________________________________________________________________
batch_normalization_621 (BatchN (None, None, None, 1 480         conv2d_621[0][0]                 
__________________________________________________________________________________________________
activation_616 (Activation)     (None, None, None, 1 0           batch_normalization_616[0][0]    
__________________________________________________________________________________________________
activation_621 (Activation)     (None, None, None, 1 0           batch_normalization_621[0][0]    
__________________________________________________________________________________________________
average_pooling2d_59 (AveragePo (None, None, None, 7 0           mixed5[0][0]                     
__________________________________________________________________________________________________
conv2d_614 (Conv2D)             (None, None, None, 1 147456      mixed5[0][0]                     
__________________________________________________________________________________________________
conv2d_617 (Conv2D)             (None, None, None, 1 215040      activation_616[0][0]             
__________________________________________________________________________________________________
conv2d_622 (Conv2D)             (None, None, None, 1 215040      activation_621[0][0]             
__________________________________________________________________________________________________
conv2d_623 (Conv2D)             (None, None, None, 1 147456      average_pooling2d_59[0][0]       
__________________________________________________________________________________________________
batch_normalization_614 (BatchN (None, None, None, 1 576         conv2d_614[0][0]                 
__________________________________________________________________________________________________
batch_normalization_617 (BatchN (None, None, None, 1 576         conv2d_617[0][0]                 
__________________________________________________________________________________________________
batch_normalization_622 (BatchN (None, None, None, 1 576         conv2d_622[0][0]                 
__________________________________________________________________________________________________
batch_normalization_623 (BatchN (None, None, None, 1 576         conv2d_623[0][0]                 
__________________________________________________________________________________________________
activation_614 (Activation)     (None, None, None, 1 0           batch_normalization_614[0][0]    
__________________________________________________________________________________________________
activation_617 (Activation)     (None, None, None, 1 0           batch_normalization_617[0][0]    
__________________________________________________________________________________________________
activation_622 (Activation)     (None, None, None, 1 0           batch_normalization_622[0][0]    
__________________________________________________________________________________________________
activation_623 (Activation)     (None, None, None, 1 0           batch_normalization_623[0][0]    
__________________________________________________________________________________________________
mixed6 (Concatenate)            (None, None, None, 7 0           activation_614[0][0]             
                                                                 activation_617[0][0]             
                                                                 activation_622[0][0]             
                                                                 activation_623[0][0]             
__________________________________________________________________________________________________
conv2d_628 (Conv2D)             (None, None, None, 1 147456      mixed6[0][0]                     
__________________________________________________________________________________________________
batch_normalization_628 (BatchN (None, None, None, 1 576         conv2d_628[0][0]                 
__________________________________________________________________________________________________
activation_628 (Activation)     (None, None, None, 1 0           batch_normalization_628[0][0]    
__________________________________________________________________________________________________
conv2d_629 (Conv2D)             (None, None, None, 1 258048      activation_628[0][0]             
__________________________________________________________________________________________________
batch_normalization_629 (BatchN (None, None, None, 1 576         conv2d_629[0][0]                 
__________________________________________________________________________________________________
activation_629 (Activation)     (None, None, None, 1 0           batch_normalization_629[0][0]    
__________________________________________________________________________________________________
conv2d_625 (Conv2D)             (None, None, None, 1 147456      mixed6[0][0]                     
__________________________________________________________________________________________________
conv2d_630 (Conv2D)             (None, None, None, 1 258048      activation_629[0][0]             
__________________________________________________________________________________________________
batch_normalization_625 (BatchN (None, None, None, 1 576         conv2d_625[0][0]                 
__________________________________________________________________________________________________
batch_normalization_630 (BatchN (None, None, None, 1 576         conv2d_630[0][0]                 
__________________________________________________________________________________________________
activation_625 (Activation)     (None, None, None, 1 0           batch_normalization_625[0][0]    
__________________________________________________________________________________________________
activation_630 (Activation)     (None, None, None, 1 0           batch_normalization_630[0][0]    
__________________________________________________________________________________________________
conv2d_626 (Conv2D)             (None, None, None, 1 258048      activation_625[0][0]             
__________________________________________________________________________________________________
conv2d_631 (Conv2D)             (None, None, None, 1 258048      activation_630[0][0]             
__________________________________________________________________________________________________
batch_normalization_626 (BatchN (None, None, None, 1 576         conv2d_626[0][0]                 
__________________________________________________________________________________________________
batch_normalization_631 (BatchN (None, None, None, 1 576         conv2d_631[0][0]                 
__________________________________________________________________________________________________
activation_626 (Activation)     (None, None, None, 1 0           batch_normalization_626[0][0]    
__________________________________________________________________________________________________
activation_631 (Activation)     (None, None, None, 1 0           batch_normalization_631[0][0]    
__________________________________________________________________________________________________
average_pooling2d_60 (AveragePo (None, None, None, 7 0           mixed6[0][0]                     
__________________________________________________________________________________________________
conv2d_624 (Conv2D)             (None, None, None, 1 147456      mixed6[0][0]                     
__________________________________________________________________________________________________
conv2d_627 (Conv2D)             (None, None, None, 1 258048      activation_626[0][0]             
__________________________________________________________________________________________________
conv2d_632 (Conv2D)             (None, None, None, 1 258048      activation_631[0][0]             
__________________________________________________________________________________________________
conv2d_633 (Conv2D)             (None, None, None, 1 147456      average_pooling2d_60[0][0]       
__________________________________________________________________________________________________
batch_normalization_624 (BatchN (None, None, None, 1 576         conv2d_624[0][0]                 
__________________________________________________________________________________________________
batch_normalization_627 (BatchN (None, None, None, 1 576         conv2d_627[0][0]                 
__________________________________________________________________________________________________
batch_normalization_632 (BatchN (None, None, None, 1 576         conv2d_632[0][0]                 
__________________________________________________________________________________________________
batch_normalization_633 (BatchN (None, None, None, 1 576         conv2d_633[0][0]                 
__________________________________________________________________________________________________
activation_624 (Activation)     (None, None, None, 1 0           batch_normalization_624[0][0]    
__________________________________________________________________________________________________
activation_627 (Activation)     (None, None, None, 1 0           batch_normalization_627[0][0]    
__________________________________________________________________________________________________
activation_632 (Activation)     (None, None, None, 1 0           batch_normalization_632[0][0]    
__________________________________________________________________________________________________
activation_633 (Activation)     (None, None, None, 1 0           batch_normalization_633[0][0]    
__________________________________________________________________________________________________
mixed7 (Concatenate)            (None, None, None, 7 0           activation_624[0][0]             
                                                                 activation_627[0][0]             
                                                                 activation_632[0][0]             
                                                                 activation_633[0][0]             
__________________________________________________________________________________________________
conv2d_636 (Conv2D)             (None, None, None, 1 147456      mixed7[0][0]                     
__________________________________________________________________________________________________
batch_normalization_636 (BatchN (None, None, None, 1 576         conv2d_636[0][0]                 
__________________________________________________________________________________________________
activation_636 (Activation)     (None, None, None, 1 0           batch_normalization_636[0][0]    
__________________________________________________________________________________________________
conv2d_637 (Conv2D)             (None, None, None, 1 258048      activation_636[0][0]             
__________________________________________________________________________________________________
batch_normalization_637 (BatchN (None, None, None, 1 576         conv2d_637[0][0]                 
__________________________________________________________________________________________________
activation_637 (Activation)     (None, None, None, 1 0           batch_normalization_637[0][0]    
__________________________________________________________________________________________________
conv2d_634 (Conv2D)             (None, None, None, 1 147456      mixed7[0][0]                     
__________________________________________________________________________________________________
conv2d_638 (Conv2D)             (None, None, None, 1 258048      activation_637[0][0]             
__________________________________________________________________________________________________
batch_normalization_634 (BatchN (None, None, None, 1 576         conv2d_634[0][0]                 
__________________________________________________________________________________________________
batch_normalization_638 (BatchN (None, None, None, 1 576         conv2d_638[0][0]                 
__________________________________________________________________________________________________
activation_634 (Activation)     (None, None, None, 1 0           batch_normalization_634[0][0]    
__________________________________________________________________________________________________
activation_638 (Activation)     (None, None, None, 1 0           batch_normalization_638[0][0]    
__________________________________________________________________________________________________
conv2d_635 (Conv2D)             (None, None, None, 3 552960      activation_634[0][0]             
__________________________________________________________________________________________________
conv2d_639 (Conv2D)             (None, None, None, 1 331776      activation_638[0][0]             
__________________________________________________________________________________________________
batch_normalization_635 (BatchN (None, None, None, 3 960         conv2d_635[0][0]                 
__________________________________________________________________________________________________
batch_normalization_639 (BatchN (None, None, None, 1 576         conv2d_639[0][0]                 
__________________________________________________________________________________________________
activation_635 (Activation)     (None, None, None, 3 0           batch_normalization_635[0][0]    
__________________________________________________________________________________________________
activation_639 (Activation)     (None, None, None, 1 0           batch_normalization_639[0][0]    
__________________________________________________________________________________________________
max_pooling2d_27 (MaxPooling2D) (None, None, None, 7 0           mixed7[0][0]                     
__________________________________________________________________________________________________
mixed8 (Concatenate)            (None, None, None, 1 0           activation_635[0][0]             
                                                                 activation_639[0][0]             
                                                                 max_pooling2d_27[0][0]           
__________________________________________________________________________________________________
conv2d_644 (Conv2D)             (None, None, None, 4 573440      mixed8[0][0]                     
__________________________________________________________________________________________________
batch_normalization_644 (BatchN (None, None, None, 4 1344        conv2d_644[0][0]                 
__________________________________________________________________________________________________
activation_644 (Activation)     (None, None, None, 4 0           batch_normalization_644[0][0]    
__________________________________________________________________________________________________
conv2d_641 (Conv2D)             (None, None, None, 3 491520      mixed8[0][0]                     
__________________________________________________________________________________________________
conv2d_645 (Conv2D)             (None, None, None, 3 1548288     activation_644[0][0]             
__________________________________________________________________________________________________
batch_normalization_641 (BatchN (None, None, None, 3 1152        conv2d_641[0][0]                 
__________________________________________________________________________________________________
batch_normalization_645 (BatchN (None, None, None, 3 1152        conv2d_645[0][0]                 
__________________________________________________________________________________________________
activation_641 (Activation)     (None, None, None, 3 0           batch_normalization_641[0][0]    
__________________________________________________________________________________________________
activation_645 (Activation)     (None, None, None, 3 0           batch_normalization_645[0][0]    
__________________________________________________________________________________________________
conv2d_642 (Conv2D)             (None, None, None, 3 442368      activation_641[0][0]             
__________________________________________________________________________________________________
conv2d_643 (Conv2D)             (None, None, None, 3 442368      activation_641[0][0]             
__________________________________________________________________________________________________
conv2d_646 (Conv2D)             (None, None, None, 3 442368      activation_645[0][0]             
__________________________________________________________________________________________________
conv2d_647 (Conv2D)             (None, None, None, 3 442368      activation_645[0][0]             
__________________________________________________________________________________________________
average_pooling2d_61 (AveragePo (None, None, None, 1 0           mixed8[0][0]                     
__________________________________________________________________________________________________
conv2d_640 (Conv2D)             (None, None, None, 3 409600      mixed8[0][0]                     
__________________________________________________________________________________________________
batch_normalization_642 (BatchN (None, None, None, 3 1152        conv2d_642[0][0]                 
__________________________________________________________________________________________________
batch_normalization_643 (BatchN (None, None, None, 3 1152        conv2d_643[0][0]                 
__________________________________________________________________________________________________
batch_normalization_646 (BatchN (None, None, None, 3 1152        conv2d_646[0][0]                 
__________________________________________________________________________________________________
batch_normalization_647 (BatchN (None, None, None, 3 1152        conv2d_647[0][0]                 
__________________________________________________________________________________________________
conv2d_648 (Conv2D)             (None, None, None, 1 245760      average_pooling2d_61[0][0]       
__________________________________________________________________________________________________
batch_normalization_640 (BatchN (None, None, None, 3 960         conv2d_640[0][0]                 
__________________________________________________________________________________________________
activation_642 (Activation)     (None, None, None, 3 0           batch_normalization_642[0][0]    
__________________________________________________________________________________________________
activation_643 (Activation)     (None, None, None, 3 0           batch_normalization_643[0][0]    
__________________________________________________________________________________________________
activation_646 (Activation)     (None, None, None, 3 0           batch_normalization_646[0][0]    
__________________________________________________________________________________________________
activation_647 (Activation)     (None, None, None, 3 0           batch_normalization_647[0][0]    
__________________________________________________________________________________________________
batch_normalization_648 (BatchN (None, None, None, 1 576         conv2d_648[0][0]                 
__________________________________________________________________________________________________
activation_640 (Activation)     (None, None, None, 3 0           batch_normalization_640[0][0]    
__________________________________________________________________________________________________
mixed9_0 (Concatenate)          (None, None, None, 7 0           activation_642[0][0]             
                                                                 activation_643[0][0]             
__________________________________________________________________________________________________
concatenate_12 (Concatenate)    (None, None, None, 7 0           activation_646[0][0]             
                                                                 activation_647[0][0]             
__________________________________________________________________________________________________
activation_648 (Activation)     (None, None, None, 1 0           batch_normalization_648[0][0]    
__________________________________________________________________________________________________
mixed9 (Concatenate)            (None, None, None, 2 0           activation_640[0][0]             
                                                                 mixed9_0[0][0]                   
                                                                 concatenate_12[0][0]             
                                                                 activation_648[0][0]             
__________________________________________________________________________________________________
conv2d_653 (Conv2D)             (None, None, None, 4 917504      mixed9[0][0]                     
__________________________________________________________________________________________________
batch_normalization_653 (BatchN (None, None, None, 4 1344        conv2d_653[0][0]                 
__________________________________________________________________________________________________
activation_653 (Activation)     (None, None, None, 4 0           batch_normalization_653[0][0]    
__________________________________________________________________________________________________
conv2d_650 (Conv2D)             (None, None, None, 3 786432      mixed9[0][0]                     
__________________________________________________________________________________________________
conv2d_654 (Conv2D)             (None, None, None, 3 1548288     activation_653[0][0]             
__________________________________________________________________________________________________
batch_normalization_650 (BatchN (None, None, None, 3 1152        conv2d_650[0][0]                 
__________________________________________________________________________________________________
batch_normalization_654 (BatchN (None, None, None, 3 1152        conv2d_654[0][0]                 
__________________________________________________________________________________________________
activation_650 (Activation)     (None, None, None, 3 0           batch_normalization_650[0][0]    
__________________________________________________________________________________________________
activation_654 (Activation)     (None, None, None, 3 0           batch_normalization_654[0][0]    
__________________________________________________________________________________________________
conv2d_651 (Conv2D)             (None, None, None, 3 442368      activation_650[0][0]             
__________________________________________________________________________________________________
conv2d_652 (Conv2D)             (None, None, None, 3 442368      activation_650[0][0]             
__________________________________________________________________________________________________
conv2d_655 (Conv2D)             (None, None, None, 3 442368      activation_654[0][0]             
__________________________________________________________________________________________________
conv2d_656 (Conv2D)             (None, None, None, 3 442368      activation_654[0][0]             
__________________________________________________________________________________________________
average_pooling2d_62 (AveragePo (None, None, None, 2 0           mixed9[0][0]                     
__________________________________________________________________________________________________
conv2d_649 (Conv2D)             (None, None, None, 3 655360      mixed9[0][0]                     
__________________________________________________________________________________________________
batch_normalization_651 (BatchN (None, None, None, 3 1152        conv2d_651[0][0]                 
__________________________________________________________________________________________________
batch_normalization_652 (BatchN (None, None, None, 3 1152        conv2d_652[0][0]                 
__________________________________________________________________________________________________
batch_normalization_655 (BatchN (None, None, None, 3 1152        conv2d_655[0][0]                 
__________________________________________________________________________________________________
batch_normalization_656 (BatchN (None, None, None, 3 1152        conv2d_656[0][0]                 
__________________________________________________________________________________________________
conv2d_657 (Conv2D)             (None, None, None, 1 393216      average_pooling2d_62[0][0]       
__________________________________________________________________________________________________
batch_normalization_649 (BatchN (None, None, None, 3 960         conv2d_649[0][0]                 
__________________________________________________________________________________________________
activation_651 (Activation)     (None, None, None, 3 0           batch_normalization_651[0][0]    
__________________________________________________________________________________________________
activation_652 (Activation)     (None, None, None, 3 0           batch_normalization_652[0][0]    
__________________________________________________________________________________________________
activation_655 (Activation)     (None, None, None, 3 0           batch_normalization_655[0][0]    
__________________________________________________________________________________________________
activation_656 (Activation)     (None, None, None, 3 0           batch_normalization_656[0][0]    
__________________________________________________________________________________________________
batch_normalization_657 (BatchN (None, None, None, 1 576         conv2d_657[0][0]                 
__________________________________________________________________________________________________
activation_649 (Activation)     (None, None, None, 3 0           batch_normalization_649[0][0]    
__________________________________________________________________________________________________
mixed9_1 (Concatenate)          (None, None, None, 7 0           activation_651[0][0]             
                                                                 activation_652[0][0]             
__________________________________________________________________________________________________
concatenate_13 (Concatenate)    (None, None, None, 7 0           activation_655[0][0]             
                                                                 activation_656[0][0]             
__________________________________________________________________________________________________
activation_657 (Activation)     (None, None, None, 1 0           batch_normalization_657[0][0]    
__________________________________________________________________________________________________
mixed10 (Concatenate)           (None, None, None, 2 0           activation_649[0][0]             
                                                                 mixed9_1[0][0]                   
                                                                 concatenate_13[0][0]             
                                                                 activation_657[0][0]             
==================================================================================================
Total params: 21,802,784
Trainable params: 21,768,352
Non-trainable params: 34,432
__________________________________________________________________________________________________

2.选择卷积层和通道

# 最大限度的激活这些层的指定的层
# layer_names = 'activation_468'
layer_names = ['activation_657','mixed10']

layers = [base_model.get_layer(name).output for name in layer_names]
layers
[<KerasTensor: shape=(None, None, None, 192) dtype=float32 (created by layer 'activation_657')>,
 <KerasTensor: shape=(None, None, None, 2048) dtype=float32 (created by layer 'mixed10')>]

3.创建特征提取模型

dream_model = tf.keras.Model(inputs=base_model.input,outputs=layers)
dream_model.summary()
Model: "model_3"
__________________________________________________________________________________________________
Layer (type)                    Output Shape         Param #     Connected to                     
==================================================================================================
input_7 (InputLayer)            [(None, None, None,  0                                            
__________________________________________________________________________________________________
conv2d_564 (Conv2D)             (None, None, None, 3 864         input_7[0][0]                    
__________________________________________________________________________________________________
batch_normalization_564 (BatchN (None, None, None, 3 96          conv2d_564[0][0]                 
__________________________________________________________________________________________________
activation_564 (Activation)     (None, None, None, 3 0           batch_normalization_564[0][0]    
__________________________________________________________________________________________________
conv2d_565 (Conv2D)             (None, None, None, 3 9216        activation_564[0][0]             
__________________________________________________________________________________________________
batch_normalization_565 (BatchN (None, None, None, 3 96          conv2d_565[0][0]                 
__________________________________________________________________________________________________
activation_565 (Activation)     (None, None, None, 3 0           batch_normalization_565[0][0]    
__________________________________________________________________________________________________
conv2d_566 (Conv2D)             (None, None, None, 6 18432       activation_565[0][0]             
__________________________________________________________________________________________________
batch_normalization_566 (BatchN (None, None, None, 6 192         conv2d_566[0][0]                 
__________________________________________________________________________________________________
activation_566 (Activation)     (None, None, None, 6 0           batch_normalization_566[0][0]    
__________________________________________________________________________________________________
max_pooling2d_24 (MaxPooling2D) (None, None, None, 6 0           activation_566[0][0]             
__________________________________________________________________________________________________
conv2d_567 (Conv2D)             (None, None, None, 8 5120        max_pooling2d_24[0][0]           
__________________________________________________________________________________________________
batch_normalization_567 (BatchN (None, None, None, 8 240         conv2d_567[0][0]                 
__________________________________________________________________________________________________
activation_567 (Activation)     (None, None, None, 8 0           batch_normalization_567[0][0]    
__________________________________________________________________________________________________
conv2d_568 (Conv2D)             (None, None, None, 1 138240      activation_567[0][0]             
__________________________________________________________________________________________________
batch_normalization_568 (BatchN (None, None, None, 1 576         conv2d_568[0][0]                 
__________________________________________________________________________________________________
activation_568 (Activation)     (None, None, None, 1 0           batch_normalization_568[0][0]    
__________________________________________________________________________________________________
max_pooling2d_25 (MaxPooling2D) (None, None, None, 1 0           activation_568[0][0]             
__________________________________________________________________________________________________
conv2d_572 (Conv2D)             (None, None, None, 6 12288       max_pooling2d_25[0][0]           
__________________________________________________________________________________________________
batch_normalization_572 (BatchN (None, None, None, 6 192         conv2d_572[0][0]                 
__________________________________________________________________________________________________
activation_572 (Activation)     (None, None, None, 6 0           batch_normalization_572[0][0]    
__________________________________________________________________________________________________
conv2d_570 (Conv2D)             (None, None, None, 4 9216        max_pooling2d_25[0][0]           
__________________________________________________________________________________________________
conv2d_573 (Conv2D)             (None, None, None, 9 55296       activation_572[0][0]             
__________________________________________________________________________________________________
batch_normalization_570 (BatchN (None, None, None, 4 144         conv2d_570[0][0]                 
__________________________________________________________________________________________________
batch_normalization_573 (BatchN (None, None, None, 9 288         conv2d_573[0][0]                 
__________________________________________________________________________________________________
activation_570 (Activation)     (None, None, None, 4 0           batch_normalization_570[0][0]    
__________________________________________________________________________________________________
activation_573 (Activation)     (None, None, None, 9 0           batch_normalization_573[0][0]    
__________________________________________________________________________________________________
average_pooling2d_54 (AveragePo (None, None, None, 1 0           max_pooling2d_25[0][0]           
__________________________________________________________________________________________________
conv2d_569 (Conv2D)             (None, None, None, 6 12288       max_pooling2d_25[0][0]           
__________________________________________________________________________________________________
conv2d_571 (Conv2D)             (None, None, None, 6 76800       activation_570[0][0]             
__________________________________________________________________________________________________
conv2d_574 (Conv2D)             (None, None, None, 9 82944       activation_573[0][0]             
__________________________________________________________________________________________________
conv2d_575 (Conv2D)             (None, None, None, 3 6144        average_pooling2d_54[0][0]       
__________________________________________________________________________________________________
batch_normalization_569 (BatchN (None, None, None, 6 192         conv2d_569[0][0]                 
__________________________________________________________________________________________________
batch_normalization_571 (BatchN (None, None, None, 6 192         conv2d_571[0][0]                 
__________________________________________________________________________________________________
batch_normalization_574 (BatchN (None, None, None, 9 288         conv2d_574[0][0]                 
__________________________________________________________________________________________________
batch_normalization_575 (BatchN (None, None, None, 3 96          conv2d_575[0][0]                 
__________________________________________________________________________________________________
activation_569 (Activation)     (None, None, None, 6 0           batch_normalization_569[0][0]    
__________________________________________________________________________________________________
activation_571 (Activation)     (None, None, None, 6 0           batch_normalization_571[0][0]    
__________________________________________________________________________________________________
activation_574 (Activation)     (None, None, None, 9 0           batch_normalization_574[0][0]    
__________________________________________________________________________________________________
activation_575 (Activation)     (None, None, None, 3 0           batch_normalization_575[0][0]    
__________________________________________________________________________________________________
mixed0 (Concatenate)            (None, None, None, 2 0           activation_569[0][0]             
                                                                 activation_571[0][0]             
                                                                 activation_574[0][0]             
                                                                 activation_575[0][0]             
__________________________________________________________________________________________________
conv2d_579 (Conv2D)             (None, None, None, 6 16384       mixed0[0][0]                     
__________________________________________________________________________________________________
batch_normalization_579 (BatchN (None, None, None, 6 192         conv2d_579[0][0]                 
__________________________________________________________________________________________________
activation_579 (Activation)     (None, None, None, 6 0           batch_normalization_579[0][0]    
__________________________________________________________________________________________________
conv2d_577 (Conv2D)             (None, None, None, 4 12288       mixed0[0][0]                     
__________________________________________________________________________________________________
conv2d_580 (Conv2D)             (None, None, None, 9 55296       activation_579[0][0]             
__________________________________________________________________________________________________
batch_normalization_577 (BatchN (None, None, None, 4 144         conv2d_577[0][0]                 
__________________________________________________________________________________________________
batch_normalization_580 (BatchN (None, None, None, 9 288         conv2d_580[0][0]                 
__________________________________________________________________________________________________
activation_577 (Activation)     (None, None, None, 4 0           batch_normalization_577[0][0]    
__________________________________________________________________________________________________
activation_580 (Activation)     (None, None, None, 9 0           batch_normalization_580[0][0]    
__________________________________________________________________________________________________
average_pooling2d_55 (AveragePo (None, None, None, 2 0           mixed0[0][0]                     
__________________________________________________________________________________________________
conv2d_576 (Conv2D)             (None, None, None, 6 16384       mixed0[0][0]                     
__________________________________________________________________________________________________
conv2d_578 (Conv2D)             (None, None, None, 6 76800       activation_577[0][0]             
__________________________________________________________________________________________________
conv2d_581 (Conv2D)             (None, None, None, 9 82944       activation_580[0][0]             
__________________________________________________________________________________________________
conv2d_582 (Conv2D)             (None, None, None, 6 16384       average_pooling2d_55[0][0]       
__________________________________________________________________________________________________
batch_normalization_576 (BatchN (None, None, None, 6 192         conv2d_576[0][0]                 
__________________________________________________________________________________________________
batch_normalization_578 (BatchN (None, None, None, 6 192         conv2d_578[0][0]                 
__________________________________________________________________________________________________
batch_normalization_581 (BatchN (None, None, None, 9 288         conv2d_581[0][0]                 
__________________________________________________________________________________________________
batch_normalization_582 (BatchN (None, None, None, 6 192         conv2d_582[0][0]                 
__________________________________________________________________________________________________
activation_576 (Activation)     (None, None, None, 6 0           batch_normalization_576[0][0]    
__________________________________________________________________________________________________
activation_578 (Activation)     (None, None, None, 6 0           batch_normalization_578[0][0]    
__________________________________________________________________________________________________
activation_581 (Activation)     (None, None, None, 9 0           batch_normalization_581[0][0]    
__________________________________________________________________________________________________
activation_582 (Activation)     (None, None, None, 6 0           batch_normalization_582[0][0]    
__________________________________________________________________________________________________
mixed1 (Concatenate)            (None, None, None, 2 0           activation_576[0][0]             
                                                                 activation_578[0][0]             
                                                                 activation_581[0][0]             
                                                                 activation_582[0][0]             
__________________________________________________________________________________________________
conv2d_586 (Conv2D)             (None, None, None, 6 18432       mixed1[0][0]                     
__________________________________________________________________________________________________
batch_normalization_586 (BatchN (None, None, None, 6 192         conv2d_586[0][0]                 
__________________________________________________________________________________________________
activation_586 (Activation)     (None, None, None, 6 0           batch_normalization_586[0][0]    
__________________________________________________________________________________________________
conv2d_584 (Conv2D)             (None, None, None, 4 13824       mixed1[0][0]                     
__________________________________________________________________________________________________
conv2d_587 (Conv2D)             (None, None, None, 9 55296       activation_586[0][0]             
__________________________________________________________________________________________________
batch_normalization_584 (BatchN (None, None, None, 4 144         conv2d_584[0][0]                 
__________________________________________________________________________________________________
batch_normalization_587 (BatchN (None, None, None, 9 288         conv2d_587[0][0]                 
__________________________________________________________________________________________________
activation_584 (Activation)     (None, None, None, 4 0           batch_normalization_584[0][0]    
__________________________________________________________________________________________________
activation_587 (Activation)     (None, None, None, 9 0           batch_normalization_587[0][0]    
__________________________________________________________________________________________________
average_pooling2d_56 (AveragePo (None, None, None, 2 0           mixed1[0][0]                     
__________________________________________________________________________________________________
conv2d_583 (Conv2D)             (None, None, None, 6 18432       mixed1[0][0]                     
__________________________________________________________________________________________________
conv2d_585 (Conv2D)             (None, None, None, 6 76800       activation_584[0][0]             
__________________________________________________________________________________________________
conv2d_588 (Conv2D)             (None, None, None, 9 82944       activation_587[0][0]             
__________________________________________________________________________________________________
conv2d_589 (Conv2D)             (None, None, None, 6 18432       average_pooling2d_56[0][0]       
__________________________________________________________________________________________________
batch_normalization_583 (BatchN (None, None, None, 6 192         conv2d_583[0][0]                 
__________________________________________________________________________________________________
batch_normalization_585 (BatchN (None, None, None, 6 192         conv2d_585[0][0]                 
__________________________________________________________________________________________________
batch_normalization_588 (BatchN (None, None, None, 9 288         conv2d_588[0][0]                 
__________________________________________________________________________________________________
batch_normalization_589 (BatchN (None, None, None, 6 192         conv2d_589[0][0]                 
__________________________________________________________________________________________________
activation_583 (Activation)     (None, None, None, 6 0           batch_normalization_583[0][0]    
__________________________________________________________________________________________________
activation_585 (Activation)     (None, None, None, 6 0           batch_normalization_585[0][0]    
__________________________________________________________________________________________________
activation_588 (Activation)     (None, None, None, 9 0           batch_normalization_588[0][0]    
__________________________________________________________________________________________________
activation_589 (Activation)     (None, None, None, 6 0           batch_normalization_589[0][0]    
__________________________________________________________________________________________________
mixed2 (Concatenate)            (None, None, None, 2 0           activation_583[0][0]             
                                                                 activation_585[0][0]             
                                                                 activation_588[0][0]             
                                                                 activation_589[0][0]             
__________________________________________________________________________________________________
conv2d_591 (Conv2D)             (None, None, None, 6 18432       mixed2[0][0]                     
__________________________________________________________________________________________________
batch_normalization_591 (BatchN (None, None, None, 6 192         conv2d_591[0][0]                 
__________________________________________________________________________________________________
activation_591 (Activation)     (None, None, None, 6 0           batch_normalization_591[0][0]    
__________________________________________________________________________________________________
conv2d_592 (Conv2D)             (None, None, None, 9 55296       activation_591[0][0]             
__________________________________________________________________________________________________
batch_normalization_592 (BatchN (None, None, None, 9 288         conv2d_592[0][0]                 
__________________________________________________________________________________________________
activation_592 (Activation)     (None, None, None, 9 0           batch_normalization_592[0][0]    
__________________________________________________________________________________________________
conv2d_590 (Conv2D)             (None, None, None, 3 995328      mixed2[0][0]                     
__________________________________________________________________________________________________
conv2d_593 (Conv2D)             (None, None, None, 9 82944       activation_592[0][0]             
__________________________________________________________________________________________________
batch_normalization_590 (BatchN (None, None, None, 3 1152        conv2d_590[0][0]                 
__________________________________________________________________________________________________
batch_normalization_593 (BatchN (None, None, None, 9 288         conv2d_593[0][0]                 
__________________________________________________________________________________________________
activation_590 (Activation)     (None, None, None, 3 0           batch_normalization_590[0][0]    
__________________________________________________________________________________________________
activation_593 (Activation)     (None, None, None, 9 0           batch_normalization_593[0][0]    
__________________________________________________________________________________________________
max_pooling2d_26 (MaxPooling2D) (None, None, None, 2 0           mixed2[0][0]                     
__________________________________________________________________________________________________
mixed3 (Concatenate)            (None, None, None, 7 0           activation_590[0][0]             
                                                                 activation_593[0][0]             
                                                                 max_pooling2d_26[0][0]           
__________________________________________________________________________________________________
conv2d_598 (Conv2D)             (None, None, None, 1 98304       mixed3[0][0]                     
__________________________________________________________________________________________________
batch_normalization_598 (BatchN (None, None, None, 1 384         conv2d_598[0][0]                 
__________________________________________________________________________________________________
activation_598 (Activation)     (None, None, None, 1 0           batch_normalization_598[0][0]    
__________________________________________________________________________________________________
conv2d_599 (Conv2D)             (None, None, None, 1 114688      activation_598[0][0]             
__________________________________________________________________________________________________
batch_normalization_599 (BatchN (None, None, None, 1 384         conv2d_599[0][0]                 
__________________________________________________________________________________________________
activation_599 (Activation)     (None, None, None, 1 0           batch_normalization_599[0][0]    
__________________________________________________________________________________________________
conv2d_595 (Conv2D)             (None, None, None, 1 98304       mixed3[0][0]                     
__________________________________________________________________________________________________
conv2d_600 (Conv2D)             (None, None, None, 1 114688      activation_599[0][0]             
__________________________________________________________________________________________________
batch_normalization_595 (BatchN (None, None, None, 1 384         conv2d_595[0][0]                 
__________________________________________________________________________________________________
batch_normalization_600 (BatchN (None, None, None, 1 384         conv2d_600[0][0]                 
__________________________________________________________________________________________________
activation_595 (Activation)     (None, None, None, 1 0           batch_normalization_595[0][0]    
__________________________________________________________________________________________________
activation_600 (Activation)     (None, None, None, 1 0           batch_normalization_600[0][0]    
__________________________________________________________________________________________________
conv2d_596 (Conv2D)             (None, None, None, 1 114688      activation_595[0][0]             
__________________________________________________________________________________________________
conv2d_601 (Conv2D)             (None, None, None, 1 114688      activation_600[0][0]             
__________________________________________________________________________________________________
batch_normalization_596 (BatchN (None, None, None, 1 384         conv2d_596[0][0]                 
__________________________________________________________________________________________________
batch_normalization_601 (BatchN (None, None, None, 1 384         conv2d_601[0][0]                 
__________________________________________________________________________________________________
activation_596 (Activation)     (None, None, None, 1 0           batch_normalization_596[0][0]    
__________________________________________________________________________________________________
activation_601 (Activation)     (None, None, None, 1 0           batch_normalization_601[0][0]    
__________________________________________________________________________________________________
average_pooling2d_57 (AveragePo (None, None, None, 7 0           mixed3[0][0]                     
__________________________________________________________________________________________________
conv2d_594 (Conv2D)             (None, None, None, 1 147456      mixed3[0][0]                     
__________________________________________________________________________________________________
conv2d_597 (Conv2D)             (None, None, None, 1 172032      activation_596[0][0]             
__________________________________________________________________________________________________
conv2d_602 (Conv2D)             (None, None, None, 1 172032      activation_601[0][0]             
__________________________________________________________________________________________________
conv2d_603 (Conv2D)             (None, None, None, 1 147456      average_pooling2d_57[0][0]       
__________________________________________________________________________________________________
batch_normalization_594 (BatchN (None, None, None, 1 576         conv2d_594[0][0]                 
__________________________________________________________________________________________________
batch_normalization_597 (BatchN (None, None, None, 1 576         conv2d_597[0][0]                 
__________________________________________________________________________________________________
batch_normalization_602 (BatchN (None, None, None, 1 576         conv2d_602[0][0]                 
__________________________________________________________________________________________________
batch_normalization_603 (BatchN (None, None, None, 1 576         conv2d_603[0][0]                 
__________________________________________________________________________________________________
activation_594 (Activation)     (None, None, None, 1 0           batch_normalization_594[0][0]    
__________________________________________________________________________________________________
activation_597 (Activation)     (None, None, None, 1 0           batch_normalization_597[0][0]    
__________________________________________________________________________________________________
activation_602 (Activation)     (None, None, None, 1 0           batch_normalization_602[0][0]    
__________________________________________________________________________________________________
activation_603 (Activation)     (None, None, None, 1 0           batch_normalization_603[0][0]    
__________________________________________________________________________________________________
mixed4 (Concatenate)            (None, None, None, 7 0           activation_594[0][0]             
                                                                 activation_597[0][0]             
                                                                 activation_602[0][0]             
                                                                 activation_603[0][0]             
__________________________________________________________________________________________________
conv2d_608 (Conv2D)             (None, None, None, 1 122880      mixed4[0][0]                     
__________________________________________________________________________________________________
batch_normalization_608 (BatchN (None, None, None, 1 480         conv2d_608[0][0]                 
__________________________________________________________________________________________________
activation_608 (Activation)     (None, None, None, 1 0           batch_normalization_608[0][0]    
__________________________________________________________________________________________________
conv2d_609 (Conv2D)             (None, None, None, 1 179200      activation_608[0][0]             
__________________________________________________________________________________________________
batch_normalization_609 (BatchN (None, None, None, 1 480         conv2d_609[0][0]                 
__________________________________________________________________________________________________
activation_609 (Activation)     (None, None, None, 1 0           batch_normalization_609[0][0]    
__________________________________________________________________________________________________
conv2d_605 (Conv2D)             (None, None, None, 1 122880      mixed4[0][0]                     
__________________________________________________________________________________________________
conv2d_610 (Conv2D)             (None, None, None, 1 179200      activation_609[0][0]             
__________________________________________________________________________________________________
batch_normalization_605 (BatchN (None, None, None, 1 480         conv2d_605[0][0]                 
__________________________________________________________________________________________________
batch_normalization_610 (BatchN (None, None, None, 1 480         conv2d_610[0][0]                 
__________________________________________________________________________________________________
activation_605 (Activation)     (None, None, None, 1 0           batch_normalization_605[0][0]    
__________________________________________________________________________________________________
activation_610 (Activation)     (None, None, None, 1 0           batch_normalization_610[0][0]    
__________________________________________________________________________________________________
conv2d_606 (Conv2D)             (None, None, None, 1 179200      activation_605[0][0]             
__________________________________________________________________________________________________
conv2d_611 (Conv2D)             (None, None, None, 1 179200      activation_610[0][0]             
__________________________________________________________________________________________________
batch_normalization_606 (BatchN (None, None, None, 1 480         conv2d_606[0][0]                 
__________________________________________________________________________________________________
batch_normalization_611 (BatchN (None, None, None, 1 480         conv2d_611[0][0]                 
__________________________________________________________________________________________________
activation_606 (Activation)     (None, None, None, 1 0           batch_normalization_606[0][0]    
__________________________________________________________________________________________________
activation_611 (Activation)     (None, None, None, 1 0           batch_normalization_611[0][0]    
__________________________________________________________________________________________________
average_pooling2d_58 (AveragePo (None, None, None, 7 0           mixed4[0][0]                     
__________________________________________________________________________________________________
conv2d_604 (Conv2D)             (None, None, None, 1 147456      mixed4[0][0]                     
__________________________________________________________________________________________________
conv2d_607 (Conv2D)             (None, None, None, 1 215040      activation_606[0][0]             
__________________________________________________________________________________________________
conv2d_612 (Conv2D)             (None, None, None, 1 215040      activation_611[0][0]             
__________________________________________________________________________________________________
conv2d_613 (Conv2D)             (None, None, None, 1 147456      average_pooling2d_58[0][0]       
__________________________________________________________________________________________________
batch_normalization_604 (BatchN (None, None, None, 1 576         conv2d_604[0][0]                 
__________________________________________________________________________________________________
batch_normalization_607 (BatchN (None, None, None, 1 576         conv2d_607[0][0]                 
__________________________________________________________________________________________________
batch_normalization_612 (BatchN (None, None, None, 1 576         conv2d_612[0][0]                 
__________________________________________________________________________________________________
batch_normalization_613 (BatchN (None, None, None, 1 576         conv2d_613[0][0]                 
__________________________________________________________________________________________________
activation_604 (Activation)     (None, None, None, 1 0           batch_normalization_604[0][0]    
__________________________________________________________________________________________________
activation_607 (Activation)     (None, None, None, 1 0           batch_normalization_607[0][0]    
__________________________________________________________________________________________________
activation_612 (Activation)     (None, None, None, 1 0           batch_normalization_612[0][0]    
__________________________________________________________________________________________________
activation_613 (Activation)     (None, None, None, 1 0           batch_normalization_613[0][0]    
__________________________________________________________________________________________________
mixed5 (Concatenate)            (None, None, None, 7 0           activation_604[0][0]             
                                                                 activation_607[0][0]             
                                                                 activation_612[0][0]             
                                                                 activation_613[0][0]             
__________________________________________________________________________________________________
conv2d_618 (Conv2D)             (None, None, None, 1 122880      mixed5[0][0]                     
__________________________________________________________________________________________________
batch_normalization_618 (BatchN (None, None, None, 1 480         conv2d_618[0][0]                 
__________________________________________________________________________________________________
activation_618 (Activation)     (None, None, None, 1 0           batch_normalization_618[0][0]    
__________________________________________________________________________________________________
conv2d_619 (Conv2D)             (None, None, None, 1 179200      activation_618[0][0]             
__________________________________________________________________________________________________
batch_normalization_619 (BatchN (None, None, None, 1 480         conv2d_619[0][0]                 
__________________________________________________________________________________________________
activation_619 (Activation)     (None, None, None, 1 0           batch_normalization_619[0][0]    
__________________________________________________________________________________________________
conv2d_615 (Conv2D)             (None, None, None, 1 122880      mixed5[0][0]                     
__________________________________________________________________________________________________
conv2d_620 (Conv2D)             (None, None, None, 1 179200      activation_619[0][0]             
__________________________________________________________________________________________________
batch_normalization_615 (BatchN (None, None, None, 1 480         conv2d_615[0][0]                 
__________________________________________________________________________________________________
batch_normalization_620 (BatchN (None, None, None, 1 480         conv2d_620[0][0]                 
__________________________________________________________________________________________________
activation_615 (Activation)     (None, None, None, 1 0           batch_normalization_615[0][0]    
__________________________________________________________________________________________________
activation_620 (Activation)     (None, None, None, 1 0           batch_normalization_620[0][0]    
__________________________________________________________________________________________________
conv2d_616 (Conv2D)             (None, None, None, 1 179200      activation_615[0][0]             
__________________________________________________________________________________________________
conv2d_621 (Conv2D)             (None, None, None, 1 179200      activation_620[0][0]             
__________________________________________________________________________________________________
batch_normalization_616 (BatchN (None, None, None, 1 480         conv2d_616[0][0]                 
__________________________________________________________________________________________________
batch_normalization_621 (BatchN (None, None, None, 1 480         conv2d_621[0][0]                 
__________________________________________________________________________________________________
activation_616 (Activation)     (None, None, None, 1 0           batch_normalization_616[0][0]    
__________________________________________________________________________________________________
activation_621 (Activation)     (None, None, None, 1 0           batch_normalization_621[0][0]    
__________________________________________________________________________________________________
average_pooling2d_59 (AveragePo (None, None, None, 7 0           mixed5[0][0]                     
__________________________________________________________________________________________________
conv2d_614 (Conv2D)             (None, None, None, 1 147456      mixed5[0][0]                     
__________________________________________________________________________________________________
conv2d_617 (Conv2D)             (None, None, None, 1 215040      activation_616[0][0]             
__________________________________________________________________________________________________
conv2d_622 (Conv2D)             (None, None, None, 1 215040      activation_621[0][0]             
__________________________________________________________________________________________________
conv2d_623 (Conv2D)             (None, None, None, 1 147456      average_pooling2d_59[0][0]       
__________________________________________________________________________________________________
batch_normalization_614 (BatchN (None, None, None, 1 576         conv2d_614[0][0]                 
__________________________________________________________________________________________________
batch_normalization_617 (BatchN (None, None, None, 1 576         conv2d_617[0][0]                 
__________________________________________________________________________________________________
batch_normalization_622 (BatchN (None, None, None, 1 576         conv2d_622[0][0]                 
__________________________________________________________________________________________________
batch_normalization_623 (BatchN (None, None, None, 1 576         conv2d_623[0][0]                 
__________________________________________________________________________________________________
activation_614 (Activation)     (None, None, None, 1 0           batch_normalization_614[0][0]    
__________________________________________________________________________________________________
activation_617 (Activation)     (None, None, None, 1 0           batch_normalization_617[0][0]    
__________________________________________________________________________________________________
activation_622 (Activation)     (None, None, None, 1 0           batch_normalization_622[0][0]    
__________________________________________________________________________________________________
activation_623 (Activation)     (None, None, None, 1 0           batch_normalization_623[0][0]    
__________________________________________________________________________________________________
mixed6 (Concatenate)            (None, None, None, 7 0           activation_614[0][0]             
                                                                 activation_617[0][0]             
                                                                 activation_622[0][0]             
                                                                 activation_623[0][0]             
__________________________________________________________________________________________________
conv2d_628 (Conv2D)             (None, None, None, 1 147456      mixed6[0][0]                     
__________________________________________________________________________________________________
batch_normalization_628 (BatchN (None, None, None, 1 576         conv2d_628[0][0]                 
__________________________________________________________________________________________________
activation_628 (Activation)     (None, None, None, 1 0           batch_normalization_628[0][0]    
__________________________________________________________________________________________________
conv2d_629 (Conv2D)             (None, None, None, 1 258048      activation_628[0][0]             
__________________________________________________________________________________________________
batch_normalization_629 (BatchN (None, None, None, 1 576         conv2d_629[0][0]                 
__________________________________________________________________________________________________
activation_629 (Activation)     (None, None, None, 1 0           batch_normalization_629[0][0]    
__________________________________________________________________________________________________
conv2d_625 (Conv2D)             (None, None, None, 1 147456      mixed6[0][0]                     
__________________________________________________________________________________________________
conv2d_630 (Conv2D)             (None, None, None, 1 258048      activation_629[0][0]             
__________________________________________________________________________________________________
batch_normalization_625 (BatchN (None, None, None, 1 576         conv2d_625[0][0]                 
__________________________________________________________________________________________________
batch_normalization_630 (BatchN (None, None, None, 1 576         conv2d_630[0][0]                 
__________________________________________________________________________________________________
activation_625 (Activation)     (None, None, None, 1 0           batch_normalization_625[0][0]    
__________________________________________________________________________________________________
activation_630 (Activation)     (None, None, None, 1 0           batch_normalization_630[0][0]    
__________________________________________________________________________________________________
conv2d_626 (Conv2D)             (None, None, None, 1 258048      activation_625[0][0]             
__________________________________________________________________________________________________
conv2d_631 (Conv2D)             (None, None, None, 1 258048      activation_630[0][0]             
__________________________________________________________________________________________________
batch_normalization_626 (BatchN (None, None, None, 1 576         conv2d_626[0][0]                 
__________________________________________________________________________________________________
batch_normalization_631 (BatchN (None, None, None, 1 576         conv2d_631[0][0]                 
__________________________________________________________________________________________________
activation_626 (Activation)     (None, None, None, 1 0           batch_normalization_626[0][0]    
__________________________________________________________________________________________________
activation_631 (Activation)     (None, None, None, 1 0           batch_normalization_631[0][0]    
__________________________________________________________________________________________________
average_pooling2d_60 (AveragePo (None, None, None, 7 0           mixed6[0][0]                     
__________________________________________________________________________________________________
conv2d_624 (Conv2D)             (None, None, None, 1 147456      mixed6[0][0]                     
__________________________________________________________________________________________________
conv2d_627 (Conv2D)             (None, None, None, 1 258048      activation_626[0][0]             
__________________________________________________________________________________________________
conv2d_632 (Conv2D)             (None, None, None, 1 258048      activation_631[0][0]             
__________________________________________________________________________________________________
conv2d_633 (Conv2D)             (None, None, None, 1 147456      average_pooling2d_60[0][0]       
__________________________________________________________________________________________________
batch_normalization_624 (BatchN (None, None, None, 1 576         conv2d_624[0][0]                 
__________________________________________________________________________________________________
batch_normalization_627 (BatchN (None, None, None, 1 576         conv2d_627[0][0]                 
__________________________________________________________________________________________________
batch_normalization_632 (BatchN (None, None, None, 1 576         conv2d_632[0][0]                 
__________________________________________________________________________________________________
batch_normalization_633 (BatchN (None, None, None, 1 576         conv2d_633[0][0]                 
__________________________________________________________________________________________________
activation_624 (Activation)     (None, None, None, 1 0           batch_normalization_624[0][0]    
__________________________________________________________________________________________________
activation_627 (Activation)     (None, None, None, 1 0           batch_normalization_627[0][0]    
__________________________________________________________________________________________________
activation_632 (Activation)     (None, None, None, 1 0           batch_normalization_632[0][0]    
__________________________________________________________________________________________________
activation_633 (Activation)     (None, None, None, 1 0           batch_normalization_633[0][0]    
__________________________________________________________________________________________________
mixed7 (Concatenate)            (None, None, None, 7 0           activation_624[0][0]             
                                                                 activation_627[0][0]             
                                                                 activation_632[0][0]             
                                                                 activation_633[0][0]             
__________________________________________________________________________________________________
conv2d_636 (Conv2D)             (None, None, None, 1 147456      mixed7[0][0]                     
__________________________________________________________________________________________________
batch_normalization_636 (BatchN (None, None, None, 1 576         conv2d_636[0][0]                 
__________________________________________________________________________________________________
activation_636 (Activation)     (None, None, None, 1 0           batch_normalization_636[0][0]    
__________________________________________________________________________________________________
conv2d_637 (Conv2D)             (None, None, None, 1 258048      activation_636[0][0]             
__________________________________________________________________________________________________
batch_normalization_637 (BatchN (None, None, None, 1 576         conv2d_637[0][0]                 
__________________________________________________________________________________________________
activation_637 (Activation)     (None, None, None, 1 0           batch_normalization_637[0][0]    
__________________________________________________________________________________________________
conv2d_634 (Conv2D)             (None, None, None, 1 147456      mixed7[0][0]                     
__________________________________________________________________________________________________
conv2d_638 (Conv2D)             (None, None, None, 1 258048      activation_637[0][0]             
__________________________________________________________________________________________________
batch_normalization_634 (BatchN (None, None, None, 1 576         conv2d_634[0][0]                 
__________________________________________________________________________________________________
batch_normalization_638 (BatchN (None, None, None, 1 576         conv2d_638[0][0]                 
__________________________________________________________________________________________________
activation_634 (Activation)     (None, None, None, 1 0           batch_normalization_634[0][0]    
__________________________________________________________________________________________________
activation_638 (Activation)     (None, None, None, 1 0           batch_normalization_638[0][0]    
__________________________________________________________________________________________________
conv2d_635 (Conv2D)             (None, None, None, 3 552960      activation_634[0][0]             
__________________________________________________________________________________________________
conv2d_639 (Conv2D)             (None, None, None, 1 331776      activation_638[0][0]             
__________________________________________________________________________________________________
batch_normalization_635 (BatchN (None, None, None, 3 960         conv2d_635[0][0]                 
__________________________________________________________________________________________________
batch_normalization_639 (BatchN (None, None, None, 1 576         conv2d_639[0][0]                 
__________________________________________________________________________________________________
activation_635 (Activation)     (None, None, None, 3 0           batch_normalization_635[0][0]    
__________________________________________________________________________________________________
activation_639 (Activation)     (None, None, None, 1 0           batch_normalization_639[0][0]    
__________________________________________________________________________________________________
max_pooling2d_27 (MaxPooling2D) (None, None, None, 7 0           mixed7[0][0]                     
__________________________________________________________________________________________________
mixed8 (Concatenate)            (None, None, None, 1 0           activation_635[0][0]             
                                                                 activation_639[0][0]             
                                                                 max_pooling2d_27[0][0]           
__________________________________________________________________________________________________
conv2d_644 (Conv2D)             (None, None, None, 4 573440      mixed8[0][0]                     
__________________________________________________________________________________________________
batch_normalization_644 (BatchN (None, None, None, 4 1344        conv2d_644[0][0]                 
__________________________________________________________________________________________________
activation_644 (Activation)     (None, None, None, 4 0           batch_normalization_644[0][0]    
__________________________________________________________________________________________________
conv2d_641 (Conv2D)             (None, None, None, 3 491520      mixed8[0][0]                     
__________________________________________________________________________________________________
conv2d_645 (Conv2D)             (None, None, None, 3 1548288     activation_644[0][0]             
__________________________________________________________________________________________________
batch_normalization_641 (BatchN (None, None, None, 3 1152        conv2d_641[0][0]                 
__________________________________________________________________________________________________
batch_normalization_645 (BatchN (None, None, None, 3 1152        conv2d_645[0][0]                 
__________________________________________________________________________________________________
activation_641 (Activation)     (None, None, None, 3 0           batch_normalization_641[0][0]    
__________________________________________________________________________________________________
activation_645 (Activation)     (None, None, None, 3 0           batch_normalization_645[0][0]    
__________________________________________________________________________________________________
conv2d_642 (Conv2D)             (None, None, None, 3 442368      activation_641[0][0]             
__________________________________________________________________________________________________
conv2d_643 (Conv2D)             (None, None, None, 3 442368      activation_641[0][0]             
__________________________________________________________________________________________________
conv2d_646 (Conv2D)             (None, None, None, 3 442368      activation_645[0][0]             
__________________________________________________________________________________________________
conv2d_647 (Conv2D)             (None, None, None, 3 442368      activation_645[0][0]             
__________________________________________________________________________________________________
average_pooling2d_61 (AveragePo (None, None, None, 1 0           mixed8[0][0]                     
__________________________________________________________________________________________________
conv2d_640 (Conv2D)             (None, None, None, 3 409600      mixed8[0][0]                     
__________________________________________________________________________________________________
batch_normalization_642 (BatchN (None, None, None, 3 1152        conv2d_642[0][0]                 
__________________________________________________________________________________________________
batch_normalization_643 (BatchN (None, None, None, 3 1152        conv2d_643[0][0]                 
__________________________________________________________________________________________________
batch_normalization_646 (BatchN (None, None, None, 3 1152        conv2d_646[0][0]                 
__________________________________________________________________________________________________
batch_normalization_647 (BatchN (None, None, None, 3 1152        conv2d_647[0][0]                 
__________________________________________________________________________________________________
conv2d_648 (Conv2D)             (None, None, None, 1 245760      average_pooling2d_61[0][0]       
__________________________________________________________________________________________________
batch_normalization_640 (BatchN (None, None, None, 3 960         conv2d_640[0][0]                 
__________________________________________________________________________________________________
activation_642 (Activation)     (None, None, None, 3 0           batch_normalization_642[0][0]    
__________________________________________________________________________________________________
activation_643 (Activation)     (None, None, None, 3 0           batch_normalization_643[0][0]    
__________________________________________________________________________________________________
activation_646 (Activation)     (None, None, None, 3 0           batch_normalization_646[0][0]    
__________________________________________________________________________________________________
activation_647 (Activation)     (None, None, None, 3 0           batch_normalization_647[0][0]    
__________________________________________________________________________________________________
batch_normalization_648 (BatchN (None, None, None, 1 576         conv2d_648[0][0]                 
__________________________________________________________________________________________________
activation_640 (Activation)     (None, None, None, 3 0           batch_normalization_640[0][0]    
__________________________________________________________________________________________________
mixed9_0 (Concatenate)          (None, None, None, 7 0           activation_642[0][0]             
                                                                 activation_643[0][0]             
__________________________________________________________________________________________________
concatenate_12 (Concatenate)    (None, None, None, 7 0           activation_646[0][0]             
                                                                 activation_647[0][0]             
__________________________________________________________________________________________________
activation_648 (Activation)     (None, None, None, 1 0           batch_normalization_648[0][0]    
__________________________________________________________________________________________________
mixed9 (Concatenate)            (None, None, None, 2 0           activation_640[0][0]             
                                                                 mixed9_0[0][0]                   
                                                                 concatenate_12[0][0]             
                                                                 activation_648[0][0]             
__________________________________________________________________________________________________
conv2d_653 (Conv2D)             (None, None, None, 4 917504      mixed9[0][0]                     
__________________________________________________________________________________________________
batch_normalization_653 (BatchN (None, None, None, 4 1344        conv2d_653[0][0]                 
__________________________________________________________________________________________________
activation_653 (Activation)     (None, None, None, 4 0           batch_normalization_653[0][0]    
__________________________________________________________________________________________________
conv2d_650 (Conv2D)             (None, None, None, 3 786432      mixed9[0][0]                     
__________________________________________________________________________________________________
conv2d_654 (Conv2D)             (None, None, None, 3 1548288     activation_653[0][0]             
__________________________________________________________________________________________________
batch_normalization_650 (BatchN (None, None, None, 3 1152        conv2d_650[0][0]                 
__________________________________________________________________________________________________
batch_normalization_654 (BatchN (None, None, None, 3 1152        conv2d_654[0][0]                 
__________________________________________________________________________________________________
activation_650 (Activation)     (None, None, None, 3 0           batch_normalization_650[0][0]    
__________________________________________________________________________________________________
activation_654 (Activation)     (None, None, None, 3 0           batch_normalization_654[0][0]    
__________________________________________________________________________________________________
average_pooling2d_62 (AveragePo (None, None, None, 2 0           mixed9[0][0]                     
__________________________________________________________________________________________________
conv2d_651 (Conv2D)             (None, None, None, 3 442368      activation_650[0][0]             
__________________________________________________________________________________________________
conv2d_652 (Conv2D)             (None, None, None, 3 442368      activation_650[0][0]             
__________________________________________________________________________________________________
conv2d_655 (Conv2D)             (None, None, None, 3 442368      activation_654[0][0]             
__________________________________________________________________________________________________
conv2d_656 (Conv2D)             (None, None, None, 3 442368      activation_654[0][0]             
__________________________________________________________________________________________________
conv2d_657 (Conv2D)             (None, None, None, 1 393216      average_pooling2d_62[0][0]       
__________________________________________________________________________________________________
conv2d_649 (Conv2D)             (None, None, None, 3 655360      mixed9[0][0]                     
__________________________________________________________________________________________________
batch_normalization_651 (BatchN (None, None, None, 3 1152        conv2d_651[0][0]                 
__________________________________________________________________________________________________
batch_normalization_652 (BatchN (None, None, None, 3 1152        conv2d_652[0][0]                 
__________________________________________________________________________________________________
batch_normalization_655 (BatchN (None, None, None, 3 1152        conv2d_655[0][0]                 
__________________________________________________________________________________________________
batch_normalization_656 (BatchN (None, None, None, 3 1152        conv2d_656[0][0]                 
__________________________________________________________________________________________________
batch_normalization_657 (BatchN (None, None, None, 1 576         conv2d_657[0][0]                 
__________________________________________________________________________________________________
batch_normalization_649 (BatchN (None, None, None, 3 960         conv2d_649[0][0]                 
__________________________________________________________________________________________________
activation_651 (Activation)     (None, None, None, 3 0           batch_normalization_651[0][0]    
__________________________________________________________________________________________________
activation_652 (Activation)     (None, None, None, 3 0           batch_normalization_652[0][0]    
__________________________________________________________________________________________________
activation_655 (Activation)     (None, None, None, 3 0           batch_normalization_655[0][0]    
__________________________________________________________________________________________________
activation_656 (Activation)     (None, None, None, 3 0           batch_normalization_656[0][0]    
__________________________________________________________________________________________________
activation_657 (Activation)     (None, None, None, 1 0           batch_normalization_657[0][0]    
__________________________________________________________________________________________________
activation_649 (Activation)     (None, None, None, 3 0           batch_normalization_649[0][0]    
__________________________________________________________________________________________________
mixed9_1 (Concatenate)          (None, None, None, 7 0           activation_651[0][0]             
                                                                 activation_652[0][0]             
__________________________________________________________________________________________________
concatenate_13 (Concatenate)    (None, None, None, 7 0           activation_655[0][0]             
                                                                 activation_656[0][0]             
__________________________________________________________________________________________________
mixed10 (Concatenate)           (None, None, None, 2 0           activation_649[0][0]             
                                                                 mixed9_1[0][0]                   
                                                                 concatenate_13[0][0]             
                                                                 activation_657[0][0]             
==================================================================================================
Total params: 21,802,784
Trainable params: 21,768,352
Non-trainable params: 34,432
__________________________________________________________________________________________________

补充:防止过拟合,和本项目无关,上课记录

  • 数据集充分
  • 验证集
  • dropout层
  • 降采样(池化)

三、训练

1.计算损失

# 损失是选中层的通道输出
def loss(img,model):
  # channel = 16 # 选定第16通道,这个数不能大于48,上面的所截取的层的通道数
  channels = [16,24] 
  # 对图像进行变形,由(300,300,3)扩展为(1,300,300,3)符合InceptionV3网络的输入特点
  img = tf.expand_dims(img,axis=0)
  # print(f'img.shape{img.shape}')
  
  res = model(img)
  # print(f'res.shape{res.shape}')
  # 取选中通道的值
  # act_res = res[:,:,:,channel]
  losses = []
  # for c in channels:
    # act = res[:,:,:,c]
    # loss = tf.reduce_mean(act)
    # losses.append(act)

  for re in res:
    loss_ = tf.reduce_mean(re)
    losses.append(loss_)
  # 选中通道的输出结果求均值
  # loss = tf.reduce_mean(act_res)
  # return loss
  return tf.reduce_sum(losses)

2.定义图像优化过程(梯度上升)

# 计算梯度
def grad(img,model):
  with tf.GradientTape() as tape:
    tape.watch(img)
    loss_ = loss(img,model)
  return tape.gradient(loss_,img),loss_
def deep_dream(model,img,epochs=100,step_size=0.01,verbose=1):
  '''
  model:模型
  img:输入的图像numpy数组
  epochs:训练的轮数
  step_size:类似于学习率
  verbose:显示过程信息,这里是自定义的
  '''
  for step in range(epochs):
    # 计算图像的梯度
    grads,loss_ = grad(img,model)
    # 归一化梯度值
    grads /= tf.math.reduce_std(grads) + 1e-8
    # 梯度上升
    img += grads*step_size
    # 功能:可以将一个张量中的数值限制在一个范围之内。(可以避免一些运算错误:可以保证在进行log运算时,不会出现log0这样的错误或者大于1的概率)
    img = tf.clip_by_value(img,-1,1) 
    # 输出过程提示信息
    if (verbose==1):
      if((step+1)%10 ==1):
        print(f'Step{step+1}/{epochs},loss{loss_}')
  return img

四、应用

1.数据预处理

# 定义图像噪声 (输入)
img_noise = np.random.uniform(size=(300,300,3))+100.0
img_noise = img_noise.astype(np.float32)
show_image(normalize_image(img_noise))

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-ZuPsG4M2-1633621084684)(output_31_0.png)]

# Inception_v3对输入的图像进行预处理,输出float32的array或者tensor,值域在-1-1之间
img = tf.keras.applications.inception_v3.preprocess_input(img_noise)
print(type(img))
img = tf.convert_to_tensor(img) # 将给定值转换为张量。
# img = tf.constant(img)
print(type(img))
<class 'numpy.ndarray'>
<class 'tensorflow.python.framework.ops.EagerTensor'>

2.应用模型

# 开始做梦
import time
start = time.time()
print('开始做梦…')

# 调用优化过程
dream_img = deep_dream(dream_model,img)

end = time.time()
print('梦醒了…')

# 标准化图像
dream_img = normalize_image(dream_img)
# 显示结果图像
show_image(dream_img)
# 保存结果图像
file_name = f'deepdream_{layer_names}.jpg'
save_image(dream_img,file_name)
print(f'梦境保存为{file_name}')
开始做梦…
Step1/100,loss0.252236932516098
Step11/100,loss1.2656019926071167
Step21/100,loss1.9856173992156982
Step31/100,loss2.584019184112549
Step41/100,loss3.2143173217773438
Step51/100,loss3.638009548187256
Step61/100,loss4.511740684509277
Step71/100,loss4.6764373779296875
Step81/100,loss5.041273593902588
Step91/100,loss5.55682373046875
梦醒了…

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-WsR4Rlec-1633621084686)(output_34_1.png)]

梦境保存为deepdream_['activation_657', 'mixed10'].jpg
继续加油,努力到问心无愧即可
  人工智能 最新文章
2022吴恩达机器学习课程——第二课(神经网
第十五章 规则学习
FixMatch: Simplifying Semi-Supervised Le
数据挖掘Java——Kmeans算法的实现
大脑皮层的分割方法
【翻译】GPT-3是如何工作的
论文笔记:TEACHTEXT: CrossModal Generaliz
python从零学(六)
详解Python 3.x 导入(import)
【答读者问27】backtrader不支持最新版本的
上一篇文章      下一篇文章      查看所有文章
加:2021-10-08 11:48:21  更:2021-10-08 11:48:36 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年11日历 -2024/11/27 10:25:04-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码