Skip to content

Commit 59d5cdb

Browse files
committed
Fix bug in densenet
1 parent 5ced4d2 commit 59d5cdb

File tree

3 files changed

+10
-11
lines changed

3 files changed

+10
-11
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ For ResNet, see : https://github.com/calmisential/TensorFlow2.0_ResNet
2222
## Train
2323
1. Requirements:
2424
+ Python >= 3.6
25-
+ Tensorflow == 2.2.0-rc1
25+
+ Tensorflow >= 2.2.0rc3
2626
2. To train the network on your own dataset, you can put the dataset under the folder **original dataset**, and the directory should look like this:
2727
```
2828
|——original dataset

configuration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,5 @@
4242
# b5 = (1.6, 2.2, 456, 0.4)
4343
# b6 = (1.8, 2.6, 528, 0.5)
4444
# b7 = (2.0, 3.1, 600, 0.5)
45-
model_index = 12
45+
model_index = 21
4646

models/densenet.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,17 @@ def __init__(self, num_layers, growth_rate, drop_rate):
3535
self.growth_rate = growth_rate
3636
self.drop_rate = drop_rate
3737
self.features_list = []
38-
39-
def _make_layer(self, x, training):
40-
y = BottleNeck(growth_rate=self.growth_rate, drop_rate=self.drop_rate)(x, training=training)
41-
self.features_list.append(y)
42-
y = tf.concat(self.features_list, axis=-1)
43-
return y
38+
self.bottle_necks = []
39+
for i in range(self.num_layers):
40+
self.bottle_necks.append(BottleNeck(growth_rate=self.growth_rate, drop_rate=self.drop_rate))
4441

4542
def call(self, inputs, training=None, **kwargs):
4643
self.features_list.append(inputs)
47-
x = self._make_layer(inputs, training=training)
48-
for i in range(1, self.num_layers):
49-
x = self._make_layer(x, training=training)
44+
x = inputs
45+
for i in range(self.num_layers):
46+
y = self.bottle_necks[i](x, training=training)
47+
self.features_list.append(y)
48+
x = tf.concat(self.features_list, axis=-1)
5049
self.features_list.clear()
5150
return x
5251

0 commit comments

Comments
 (0)