Skip to content
ResNet-18 TensorFlow Implementation including conversion of torch .t7 weights into tensorflow ckpt
Branch: master
Clone or download
Latest commit 49eb67c May 8, 2018


A TensorFlow implementation of ResNet-18(


  1. TensorFlow 1.8
  2. The ImageNet dataset
  • All image files are required to be valid JPEG files. See this gist.
  • It is highly recommened for every image to be resized so that the shorter side is 256.
  1. (Optional) Torchfile(to convert ResNet-18 .t7 checkpoint into tensorflow checkpoint. Install with a command pip install torchfile)

How To Run

  • (Optional) Convert torch .t7 into tensorflow ckpt
# Download the ResNet-18 torch checkpoint
# Convert into tensorflow checkpoint
  1. Modify from scratch) or pretrained weights) to have valid values of following arguments
  • train_dataset, train_image_root, val_dataset, val_image_root: Path to the list file of train/val dataset and to the root
  • num_gpus and corresponding IDs of GPUs(CUDA_VISIBLE_DEVICES at the first line)
  1. Run!
  • ./ if you want to finetune the converted ResNet(NOTE: The model needs to be finetuned for some epochs)
  • ./ if you want to train ResNet from scratch
  1. Evaluate the trained model
  • ./ for evaluating the trained model(change the arguments in to your preference)


  • The extracted weights should be finetuned for several epochs(run ./ to get the full performance(If you run the evaluation code without finetuning, the single-crop top-1 validation accuracy is about 60%, which is less than the appeared in the original). I guess there is some minor issue that I have missed.
You can’t perform that action at this time.