Skip to content

Commit 8ca746c

Browse files
committed
Update README.
1 parent da4dc73 commit 8ca746c

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

efficientnetv2/README.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,29 @@ Finetune on CIFAR10:
6969
python main.py --mode=train --model_name=efficientnetv2-s --dataset_cfg=cifar10Ft --model_dir=$DIR --hparam_str="train.ft_init_ckpt=$PRETRAIN_CKPT_PATH"
7070

7171

72-
## 4. Inference
72+
## 4. Build a pretrained model and finetuning
73+
74+
75+
You can directly use this code to build a model like this:
76+
77+
mode = tf.keras.models.Sequential([
78+
tf.keras.layers.InputLayer(input_shape=[224, 224, 3]),
79+
effnetv2_model.get_model('efficientnetv2-b0', include_top=False, pretrained=True),
80+
tf.keras.layers.Dropout(rate=0.2),
81+
tf.keras.layers.Dense(4, activation='softmax'),
82+
])
83+
84+
Or you can also load them from tfhub:
85+
86+
hub_url = 'gs://cloud-tpu-checkpoints/efficientnet/v2/hub/efficientnetv2-b0/feature-vector'
87+
model = tf.keras.Sequential([
88+
tf.keras.layers.InputLayer(input_shape=[224, 224, 3]),
89+
hub.KerasLayer(hub_url, trainable=do_fine_tuning),
90+
tf.keras.layers.Dropout(rate=0.2),
91+
tf.keras.layers.Dense(4, activation='softmax'),
92+
])
93+
94+
## 5. Inference
7395

7496
python infer.py --model_name=efficientnetv2-m --model_dir=$MODEL_DIR
7597

0 commit comments

Comments
 (0)