这有效:
img = Input(shape=(224,224,3))
efnet = EfficientNetB0(
weights = 'noisy-student',
include_top = False,
pooling = None,
classes = None
)
for layer in efnet.layers:
layer.trainable = False
x = efnet(img)
# ... any number of layers ...
x = Dense(1)(x)
model = Model(inputs=img, outputs=x)
这不是(“图形已断开连接”):
img = Input(shape=(224,224,3))
img = Dropout(0.2)(img)
# ^ "Preprocessing" could be anything, Dropout is a simple example
efnet = EfficientNetB0(
weights = 'noisy-student',
include_top = False,
pooling = None,
classes = None
)
for layer in efnet.layers:
layer.trainable = False
x = efnet(img)
# ... any number of layers ...
x = Dense(1)(x)
model = Model(inputs=img, outputs=x)
两者之间的唯一区别是“预处理”。为什么这种方法不起作用,如何将中间层放置在输入和如上所示的“模型作为图层”之间?
(在efnet声明中指定input_shape和/或input_tensor无效。实际上,指定input_tensor神秘地导致efnet权重无法加载,因为efnet显然具有131层(???)而不是预期为130。)
答案 0 :(得分:0)
我找到了解决该问题的方法,尽管我不知道为什么该方法会有所不同。
这有效:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Title</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="shortcut icon" href="favicon.gif" type="image/x-icon" />
<link rel="icon" href="favicon.gif" type="image/xIicon" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.0/css/all.css" integrity="sha384-lZN37f5QGtY3VHgisS14W3ExzMWZxybE1SJSEsQp9S+oqd12jhcu+A56Ebc1zFSJ" crossorigin="anonymous">
<link href="https://fonts.googleapis.com/css?family=Lato:400,700&display=swap" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
<script src="https://kit.fontawesome.com/de6f7ac358.js" crossorigin="anonymous"></script>
</head>
<body>
<div class="small-nav-dropdown-menu">
<ul style="background-color: rgb(36, 204, 151);">
<li>
<a href="#">
<span style="color: #fff">Menu 1</span>
</a>
<ul class="a-new-class" style="background-color: #00bc92;">
<li>
<a href="#">
<span class="main-nav-dropdown-item-text">1.1</span>
</a>
</li>
<li>
<a href="#" class="main-nav-dropdown-item-text">1.2</a>
</li>
<li>
<a href="#" class="main-nav-dropdown-item-text">1.3</a>
</li>
<li>
<a href="#" class="main-nav-dropdown-item-text">1.4</a>
</li>
<li>
<a href="#" class="main-nav-dropdown-item-text">1.5</a>
</li>
<li>
<a href="#" class="main-nav-dropdown-item-text">1.6</a>
</li>
<li>
<a href="#">
<span class="main-nav-dropdown-item-text">1.7</span>
</a>
</li>
<li>
<a>
<span class="main-nav-dropdown-item-text">1.8</span>
</a>
</li>
</ul>
</li>
<li>
<a href="#">
<span style="color: #fff">Menu 2</span>
</a>
<ul class="a-new-class" style="background-color: #00bc92;">
<li>
<a href="#">
<span class="main-nav-dropdown-item-text">2.1</span>
</a>
</li>
<li>
<a href="#" class="main-nav-dropdown-item-text">2.2</a>
</li>
<li>
<a href="#" class="main-nav-dropdown-item-text">2.3</a>
</li>
<li>
<a href="#" class="main-nav-dropdown-item-text">2.4</a>
</li>
<li>
<a href="#" class="main-nav-dropdown-item-text">2.5</a>
</li>
<li>
<a href="#">
<span class="main-nav-dropdown-item-text">2.6</span>
</a>
</li>
<li>
<a href="#">
<span class="main-nav-dropdown-item-text">2.7</span>
</a>
</li>
</ul>
</li>
</ul>
</div>
</body>
</html>
这不是:
img = Input(shape=(224,224,3))
x = Dropout(0.2)(img)
x = efnet(x)
x = Dense(1)(x)
model = Model(inputs=img, outputs=x)