This commit is contained in:
rpotter6298
2026-07-01 17:35:58 +02:00
parent 9bfcc0243b
commit 35cbd9ac3c
84 changed files with 8500 additions and 423 deletions
+50
View File
@@ -0,0 +1,50 @@
#!/usr/bin/env python3
"""
verify_feature_dims.py
Quick check: what does TF/Keras actually output for each model
with include_top=False? Compare against manuscript claims.
"""
import numpy as np
from tensorflow.keras.applications import (
VGG16, DenseNet121, EfficientNetB1, MobileNetV2, ResNet50
)
# Match the manuscript's input sizes
models = {
"VGG16": (VGG16, 224),
"DenseNet121": (DenseNet121, 224),
"EfficientNetB1":(EfficientNetB1, 240),
"MobileNetV2": (MobileNetV2, 224),
"ResNet50": (ResNet50, 224),
}
manuscript_claims = {
"VGG16": 25088,
"DenseNet121": 50176,
"EfficientNetB1":62720,
"MobileNetV2": 62720,
"ResNet50": 100352,
}
print(f"{'Model':<18s} {'Input':>5s} {'Spatial':>10s} {'Flattened':>10s} {'Manuscript':>12s} {'Match?':>7s}")
print("-" * 70)
for name, (model_fn, input_size) in models.items():
model = model_fn(weights="imagenet", include_top=False,
input_shape=(input_size, input_size, 3))
# Pass a dummy batch through
dummy = np.random.randn(1, input_size, input_size, 3)
# Need to preprocess correctly — but shape doesn't depend on values
output = model.predict(dummy, verbose=0)
spatial = output.shape[1:4] # (H, W, C) for channels_last
flattened = int(np.prod(spatial))
claimed = manuscript_claims[name]
match = "" if flattened == claimed else ""
print(f"{name:<18s} {input_size:>4}d {str(spatial):>10s} {flattened:>10d} {claimed:>12d} {match:>7s}")
print("\nNote: TF uses channels_last (NHWC) format.")