Closed
Description
Predictions from the ResNet pre-trained models seems to have an issue. The predicted probabilities are changing at each call and essentially look like random. VGG19 does work fine however.
using Flux
using Metalhead
img = Metalhead.load("data/cats/cats_00001.jpg");
julia> classify(VGG19(), img)
"tiger cat"
julia> classify(VGG19(), img)
"tiger cat"
julia> classify(ResNet(), img)
"reel"
julia> classify(ResNet(), img)
"abacus"
julia> classify(ResNet(), img)
"spotlight, spot"
julia> classify(ResNet(), img)
"fountain"
I first though it might be an issue with a different preprocessing required for ResNet, thought from the randomness in the output of the model, I'd guess some layers didn't get properly defined, possibly the BatchNorm?
If using testmode!
, resnet will then produces the same predictions after each run. However, a different set of weights seem to be initialized right at each call to ``
resnet = ResNet().layers
testmode!(resnet)
cat_pred_resnet = resnet(preprocess(RGB.(img)))
julia> findmax(cat_pred_resnet)
(1.0f0, CartesianIndex(900, 1))
cat_pred_resnet = resnet(preprocess(RGB.(img)))
julia> findmax(cat_pred_resnet)
(1.0f0, CartesianIndex(900, 1))
resnet = ResNet().layers
testmode!(resnet)
cat_pred_resnet = resnet(preprocess(RGB.(img)))
julia> findmax(cat_pred_resnet)
(0.99877006f0, CartesianIndex(413, 1))
Metadata
Metadata
Assignees
Labels
No labels