Skip to content

Commit

Permalink
Removing softmax as terminal activation within remaining image classi…
Browse files Browse the repository at this point in the history
…fication models. (#491)
  • Loading branch information
BradLarson authored May 6, 2020
1 parent 08692fb commit b0cc1c4
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Models/ImageClassification/EfficientNet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ public struct EfficientNet: Layer {
dropoutProb = Dropout<Float>(probability: dropout)
outputClassifier = Dense(
inputSize: makeDivisible(filter: 1280, width: width),
outputSize: classCount, activation: softmax)
outputSize: classCount)
}

@differentiable
Expand Down
3 changes: 1 addition & 2 deletions Models/ImageClassification/MobileNetV2.swift
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,7 @@ public struct MobileNetV2: Layer {
outputConvBatchNorm = BatchNorm(featureCount: lastBlockFilterCount)

outputClassifier = Dense(
inputSize: lastBlockFilterCount, outputSize: classCount,
activation: softmax)
inputSize: lastBlockFilterCount, outputSize: classCount)
}

@differentiable
Expand Down
4 changes: 2 additions & 2 deletions Models/ImageClassification/MobileNetV3.swift
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ public struct MobileNetV3Large: Layer {
input.shape[0], 1, 1, self.lastConvChannel,
])
let finalConvResult = dropoutLayer(hardSwish(finalConv(averagePool)))
return softmax(flatten(classiferConv(finalConvResult)))
return flatten(classiferConv(finalConvResult))
}
}

Expand Down Expand Up @@ -473,6 +473,6 @@ public struct MobileNetV3Small: Layer {
input.shape[0], 1, 1, lastConvChannel,
])
let finalConvResult = dropoutLayer(hardSwish(finalConv(averagePool)))
return softmax(flatten(classiferConv(finalConvResult)))
return flatten(classiferConv(finalConvResult))
}
}
4 changes: 2 additions & 2 deletions Models/ImageClassification/VGG.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public struct VGG16: Layer {
layer3 = VGGBlock(featureCounts: (128, 256, 256, 256), blockCount: 3)
layer4 = VGGBlock(featureCounts: (256, 512, 512, 512), blockCount: 3)
layer5 = VGGBlock(featureCounts: (512, 512, 512, 512), blockCount: 3)
output = Dense(inputSize: 4096, outputSize: classCount, activation: softmax)
output = Dense(inputSize: 4096, outputSize: classCount)
}

@differentiable
Expand Down Expand Up @@ -86,7 +86,7 @@ public struct VGG19: Layer {
layer3 = VGGBlock(featureCounts: (128, 256, 256, 256), blockCount: 4)
layer4 = VGGBlock(featureCounts: (256, 512, 512, 512), blockCount: 4)
layer5 = VGGBlock(featureCounts: (512, 512, 512, 512), blockCount: 4)
output = Dense(inputSize: 4096, outputSize: classCount, activation: softmax)
output = Dense(inputSize: 4096, outputSize: classCount)
}

@differentiable
Expand Down
2 changes: 1 addition & 1 deletion Models/Spatiotemporal/C3D.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public struct C3D: Layer {
var output: Dense<Float>

public init(classCount: Int) {
self.output = Dense<Float>(inputSize: 1024, outputSize: classCount, activation: softmax)
self.output = Dense<Float>(inputSize: 1024, outputSize: classCount)
}

@differentiable
Expand Down

0 comments on commit b0cc1c4

Please sign in to comment.