【发布时间】:2019-12-16 00:40:46
【问题描述】:
我正在尝试使用新的 tensorflow 2 实现以下网络 Fots 进行文本检测。作者使用 resnet 作为其网络的主干,所以我的第一个想法是使用 tensoflow hub resnet 来加载预训练网络.但问题是我找不到打印从 tfhub 加载的模块摘要的方法?
有什么方法可以查看从 tf-hub 加载的模块的层? 谢谢
更新
不幸的是,tf2-hub 无法使用 resnet,所以我决定使用 resent 的内置 keras 实现,至少在有 hub impl 之前是这样。 。
这是我使用 tf2.keras.applications 获得 resnet 中间层的方法:
import numpy as np
import tensorflow as tf
from tensorflow import keras
layers_out = ["activation_9", "activation_21", "activation_39", "activation_48"]
imgs = np.random.randn(2, 640, 640, 3).astype(np.float32)
model = keras.applications.resnet50.ResNet50(input_shape=(640, 640, 3), include_top=False)
intermid_outputs= [model.get_layer(layer_name).output for layer_name in layers_out]
shared_conds = keras.Model(inputs=model.input, outputs=intermid_outputs)
Y = conv_shared(imgs)
shapes = [y.shape for y in Y]
print(shapes)
【问题讨论】: