I am trying to train with ImageNet 1k which has 1000 classes with resnet18 from NGC.
How can I change the number of output of it to 1000.
I got an error which the number of label is not matched.
File "/usr/local/lib/python3.6/dist-packages/keras/engine/training.py", line 789, in _standardize_user_data
exception_prefix='target')
File "/usr/local/lib/python3.6/dist-packages/keras/engine/training_utils.py", line 138, in standardize_input_data
str(data_shape))
ValueError: Error when checking target: expected predictions to have shape (176,) but got array with shape (1000,)
printed network is like the below
block_4c_relu (Activation) (None, 2048, 14, 14) 0 add_16[0][0]
avg_pool (AveragePooling2D) (None, 2048, 1, 1) 0 block_4c_relu[0][0]
flatten (Flatten) (None, 2048) 0 avg_pool[0][0]
predictions (Dense) (None, 176) 360624 flatten[0][0]
command
$ tlt-train classification -e i1k_r18_train.cfg -r /workspace/test1/ -k 1103
i1k_r18_train.cfg
model_config {
arch: "resnet"
n_layers: 18
use_bias: True
use_batch_norm: True
all_projections: True
use_pooling: False
freeze_bn: False
freeze_blocks: 0
freeze_blocks: 1
input_image_size: "3,224,224"
}
eval_config {
eval_dataset_path: "/dataset/ILSVRC2012/val"
model_path: "/workspace/test1"
top_k: 3
batch_size: 256
n_workers: 8
}
train_config {
train_dataset_path: "/dataset/ILSVRC2012/train"
val_dataset_path: "/dataset/ILSVRC2012/val"
pretrained_model_path: "/workspace/tlt_pretrained_classification_vresnet18/resnet_18.hdf5"
optimizer: "sgd"
batch_size_per_gpu: 64
n_epochs: 3
n_workers: 16
# regularizer
reg_config {
type: "L2"
scope: "Conv2D,Dense"
weight_decay: 0.00005
}
lr_config {
scheduler: "soft_anneal"
learning_rate: 0.005
soft_start: 0.056
annealing_points: "0.3, 0.6, 0.8"
annealing_divider: 10
}
}