Table Of Contents
Table Of Contents

4. Dive Deep into Training I3D mdoels on Kinetcis400

This is a video action recognition tutorial using Gluon CV toolkit, a step-by-step example. The readers should have basic knowledge of deep learning and should be familiar with Gluon API. New users may first go through A 60-minute Gluon Crash Course. You can Start Training Now or `Dive into Deep`_.

Start Training Now

Note

Feel free to skip the tutorial because the training script is self-complete and ready to launch.

Download Full Python Script: train_recognizer.py

For more training command options, please run python train_recognizer.py -h Please checkout the model_zoo for training commands of reproducing the pretrained model.

Network Structure

First, let’s import the necessary libraries into python.

from __future__ import division

import argparse, time, logging, os, sys, math

import numpy as np
import mxnet as mx
import gluoncv as gcv
from mxnet import gluon, nd, init, context
from mxnet import autograd as ag
from mxnet.gluon import nn
from mxnet.gluon.data.vision import transforms

from gluoncv.data.transforms import video
from gluoncv.data import Kinetics400
from gluoncv.model_zoo import get_model
from gluoncv.utils import makedirs, LRSequential, LRScheduler, split_and_load, TrainingHistory

Here we pick a widely adopted model, I3D-InceptionV1, for the tutorial. I3D (Inflated 3D Networks) is a widely adopted 3D video classification network. It uses 3D convolution to learn spatiotemporal information directly from videos. I3D is proposed to improve C3D model by inflating from 2D models. We can not only reuse the 2D models’ architecture (e.g., ResNet, Inception), but also bootstrap the model weights from 2D pretrained models. In this manner, training 3D networks for video classification is feasible and getting much better results.

# number of GPUs to use
num_gpus = 1
ctx = [mx.gpu(i) for i in range(num_gpus)]

# Get the model i3d_inceptionv1_kinetics400 with 400 output classes, without pre-trained weights
net = get_model(name='i3d_inceptionv1_kinetics400', nclass=400)
net.collect_params().reset_ctx(ctx)
print(net)

Out:

i3d_inceptionv11_conv0_weight is done with shape:  (64, 3, 7, 7, 7)
i3d_inceptionv11_batchnorm0_gamma is done with shape:  (64,)
i3d_inceptionv11_batchnorm0_beta is done with shape:  (64,)
i3d_inceptionv11_batchnorm0_running_mean is done with shape:  (64,)
i3d_inceptionv11_batchnorm0_running_var is done with shape:  (64,)
i3d_inceptionv11_conv1_weight is done with shape:  (64, 64, 1, 1, 1)
i3d_inceptionv11_batchnorm1_gamma is done with shape:  (64,)
i3d_inceptionv11_batchnorm1_beta is done with shape:  (64,)
i3d_inceptionv11_batchnorm1_running_mean is done with shape:  (64,)
i3d_inceptionv11_batchnorm1_running_var is done with shape:  (64,)
i3d_inceptionv11_conv2_weight is done with shape:  (192, 64, 3, 3, 3)
i3d_inceptionv11_batchnorm2_gamma is done with shape:  (192,)
i3d_inceptionv11_batchnorm2_beta is done with shape:  (192,)
i3d_inceptionv11_batchnorm2_running_mean is done with shape:  (192,)
i3d_inceptionv11_batchnorm2_running_var is done with shape:  (192,)
i3d_inceptionv11_Mixed_3a_conv0_weight is done with shape:  (64, 192, 1, 1, 1)
i3d_inceptionv11_Mixed_3a_batchnorm0_gamma is done with shape:  (64,)
i3d_inceptionv11_Mixed_3a_batchnorm0_beta is done with shape:  (64,)
i3d_inceptionv11_Mixed_3a_batchnorm0_running_mean is done with shape:  (64,)
i3d_inceptionv11_Mixed_3a_batchnorm0_running_var is done with shape:  (64,)
i3d_inceptionv11_Mixed_3a_conv1_weight is done with shape:  (96, 192, 1, 1, 1)
i3d_inceptionv11_Mixed_3a_batchnorm1_gamma is done with shape:  (96,)
i3d_inceptionv11_Mixed_3a_batchnorm1_beta is done with shape:  (96,)
i3d_inceptionv11_Mixed_3a_batchnorm1_running_mean is done with shape:  (96,)
i3d_inceptionv11_Mixed_3a_batchnorm1_running_var is done with shape:  (96,)
i3d_inceptionv11_Mixed_3a_conv2_weight is done with shape:  (128, 96, 3, 3, 3)
i3d_inceptionv11_Mixed_3a_batchnorm2_gamma is done with shape:  (128,)
i3d_inceptionv11_Mixed_3a_batchnorm2_beta is done with shape:  (128,)
i3d_inceptionv11_Mixed_3a_batchnorm2_running_mean is done with shape:  (128,)
i3d_inceptionv11_Mixed_3a_batchnorm2_running_var is done with shape:  (128,)
i3d_inceptionv11_Mixed_3a_conv3_weight is done with shape:  (16, 192, 1, 1, 1)
i3d_inceptionv11_Mixed_3a_batchnorm3_gamma is done with shape:  (16,)
i3d_inceptionv11_Mixed_3a_batchnorm3_beta is done with shape:  (16,)
i3d_inceptionv11_Mixed_3a_batchnorm3_running_mean is done with shape:  (16,)
i3d_inceptionv11_Mixed_3a_batchnorm3_running_var is done with shape:  (16,)
i3d_inceptionv11_Mixed_3a_conv4_weight is done with shape:  (32, 16, 3, 3, 3)
i3d_inceptionv11_Mixed_3a_batchnorm4_gamma is done with shape:  (32,)
i3d_inceptionv11_Mixed_3a_batchnorm4_beta is done with shape:  (32,)
i3d_inceptionv11_Mixed_3a_batchnorm4_running_mean is done with shape:  (32,)
i3d_inceptionv11_Mixed_3a_batchnorm4_running_var is done with shape:  (32,)
i3d_inceptionv11_Mixed_3a_conv5_weight is done with shape:  (32, 192, 1, 1, 1)
i3d_inceptionv11_Mixed_3a_batchnorm5_gamma is done with shape:  (32,)
i3d_inceptionv11_Mixed_3a_batchnorm5_beta is done with shape:  (32,)
i3d_inceptionv11_Mixed_3a_batchnorm5_running_mean is done with shape:  (32,)
i3d_inceptionv11_Mixed_3a_batchnorm5_running_var is done with shape:  (32,)
i3d_inceptionv11_Mixed_3b_conv0_weight is done with shape:  (128, 256, 1, 1, 1)
i3d_inceptionv11_Mixed_3b_batchnorm0_gamma is done with shape:  (128,)
i3d_inceptionv11_Mixed_3b_batchnorm0_beta is done with shape:  (128,)
i3d_inceptionv11_Mixed_3b_batchnorm0_running_mean is done with shape:  (128,)
i3d_inceptionv11_Mixed_3b_batchnorm0_running_var is done with shape:  (128,)
i3d_inceptionv11_Mixed_3b_conv1_weight is done with shape:  (128, 256, 1, 1, 1)
i3d_inceptionv11_Mixed_3b_batchnorm1_gamma is done with shape:  (128,)
i3d_inceptionv11_Mixed_3b_batchnorm1_beta is done with shape:  (128,)
i3d_inceptionv11_Mixed_3b_batchnorm1_running_mean is done with shape:  (128,)
i3d_inceptionv11_Mixed_3b_batchnorm1_running_var is done with shape:  (128,)
i3d_inceptionv11_Mixed_3b_conv2_weight is done with shape:  (192, 128, 3, 3, 3)
i3d_inceptionv11_Mixed_3b_batchnorm2_gamma is done with shape:  (192,)
i3d_inceptionv11_Mixed_3b_batchnorm2_beta is done with shape:  (192,)
i3d_inceptionv11_Mixed_3b_batchnorm2_running_mean is done with shape:  (192,)
i3d_inceptionv11_Mixed_3b_batchnorm2_running_var is done with shape:  (192,)
i3d_inceptionv11_Mixed_3b_conv3_weight is done with shape:  (32, 256, 1, 1, 1)
i3d_inceptionv11_Mixed_3b_batchnorm3_gamma is done with shape:  (32,)
i3d_inceptionv11_Mixed_3b_batchnorm3_beta is done with shape:  (32,)
i3d_inceptionv11_Mixed_3b_batchnorm3_running_mean is done with shape:  (32,)
i3d_inceptionv11_Mixed_3b_batchnorm3_running_var is done with shape:  (32,)
i3d_inceptionv11_Mixed_3b_conv4_weight is done with shape:  (96, 32, 3, 3, 3)
i3d_inceptionv11_Mixed_3b_batchnorm4_gamma is done with shape:  (96,)
i3d_inceptionv11_Mixed_3b_batchnorm4_beta is done with shape:  (96,)
i3d_inceptionv11_Mixed_3b_batchnorm4_running_mean is done with shape:  (96,)
i3d_inceptionv11_Mixed_3b_batchnorm4_running_var is done with shape:  (96,)
i3d_inceptionv11_Mixed_3b_conv5_weight is done with shape:  (64, 256, 1, 1, 1)
i3d_inceptionv11_Mixed_3b_batchnorm5_gamma is done with shape:  (64,)
i3d_inceptionv11_Mixed_3b_batchnorm5_beta is done with shape:  (64,)
i3d_inceptionv11_Mixed_3b_batchnorm5_running_mean is done with shape:  (64,)
i3d_inceptionv11_Mixed_3b_batchnorm5_running_var is done with shape:  (64,)
i3d_inceptionv11_Mixed_4a_conv0_weight is done with shape:  (192, 480, 1, 1, 1)
i3d_inceptionv11_Mixed_4a_batchnorm0_gamma is done with shape:  (192,)
i3d_inceptionv11_Mixed_4a_batchnorm0_beta is done with shape:  (192,)
i3d_inceptionv11_Mixed_4a_batchnorm0_running_mean is done with shape:  (192,)
i3d_inceptionv11_Mixed_4a_batchnorm0_running_var is done with shape:  (192,)
i3d_inceptionv11_Mixed_4a_conv1_weight is done with shape:  (96, 480, 1, 1, 1)
i3d_inceptionv11_Mixed_4a_batchnorm1_gamma is done with shape:  (96,)
i3d_inceptionv11_Mixed_4a_batchnorm1_beta is done with shape:  (96,)
i3d_inceptionv11_Mixed_4a_batchnorm1_running_mean is done with shape:  (96,)
i3d_inceptionv11_Mixed_4a_batchnorm1_running_var is done with shape:  (96,)
i3d_inceptionv11_Mixed_4a_conv2_weight is done with shape:  (208, 96, 3, 3, 3)
i3d_inceptionv11_Mixed_4a_batchnorm2_gamma is done with shape:  (208,)
i3d_inceptionv11_Mixed_4a_batchnorm2_beta is done with shape:  (208,)
i3d_inceptionv11_Mixed_4a_batchnorm2_running_mean is done with shape:  (208,)
i3d_inceptionv11_Mixed_4a_batchnorm2_running_var is done with shape:  (208,)
i3d_inceptionv11_Mixed_4a_conv3_weight is done with shape:  (16, 480, 1, 1, 1)
i3d_inceptionv11_Mixed_4a_batchnorm3_gamma is done with shape:  (16,)
i3d_inceptionv11_Mixed_4a_batchnorm3_beta is done with shape:  (16,)
i3d_inceptionv11_Mixed_4a_batchnorm3_running_mean is done with shape:  (16,)
i3d_inceptionv11_Mixed_4a_batchnorm3_running_var is done with shape:  (16,)
i3d_inceptionv11_Mixed_4a_conv4_weight is done with shape:  (48, 16, 3, 3, 3)
i3d_inceptionv11_Mixed_4a_batchnorm4_gamma is done with shape:  (48,)
i3d_inceptionv11_Mixed_4a_batchnorm4_beta is done with shape:  (48,)
i3d_inceptionv11_Mixed_4a_batchnorm4_running_mean is done with shape:  (48,)
i3d_inceptionv11_Mixed_4a_batchnorm4_running_var is done with shape:  (48,)
i3d_inceptionv11_Mixed_4a_conv5_weight is done with shape:  (64, 480, 1, 1, 1)
i3d_inceptionv11_Mixed_4a_batchnorm5_gamma is done with shape:  (64,)
i3d_inceptionv11_Mixed_4a_batchnorm5_beta is done with shape:  (64,)
i3d_inceptionv11_Mixed_4a_batchnorm5_running_mean is done with shape:  (64,)
i3d_inceptionv11_Mixed_4a_batchnorm5_running_var is done with shape:  (64,)
i3d_inceptionv11_Mixed_4b_conv0_weight is done with shape:  (160, 512, 1, 1, 1)
i3d_inceptionv11_Mixed_4b_batchnorm0_gamma is done with shape:  (160,)
i3d_inceptionv11_Mixed_4b_batchnorm0_beta is done with shape:  (160,)
i3d_inceptionv11_Mixed_4b_batchnorm0_running_mean is done with shape:  (160,)
i3d_inceptionv11_Mixed_4b_batchnorm0_running_var is done with shape:  (160,)
i3d_inceptionv11_Mixed_4b_conv1_weight is done with shape:  (112, 512, 1, 1, 1)
i3d_inceptionv11_Mixed_4b_batchnorm1_gamma is done with shape:  (112,)
i3d_inceptionv11_Mixed_4b_batchnorm1_beta is done with shape:  (112,)
i3d_inceptionv11_Mixed_4b_batchnorm1_running_mean is done with shape:  (112,)
i3d_inceptionv11_Mixed_4b_batchnorm1_running_var is done with shape:  (112,)
i3d_inceptionv11_Mixed_4b_conv2_weight is done with shape:  (224, 112, 3, 3, 3)
i3d_inceptionv11_Mixed_4b_batchnorm2_gamma is done with shape:  (224,)
i3d_inceptionv11_Mixed_4b_batchnorm2_beta is done with shape:  (224,)
i3d_inceptionv11_Mixed_4b_batchnorm2_running_mean is done with shape:  (224,)
i3d_inceptionv11_Mixed_4b_batchnorm2_running_var is done with shape:  (224,)
i3d_inceptionv11_Mixed_4b_conv3_weight is done with shape:  (24, 512, 1, 1, 1)
i3d_inceptionv11_Mixed_4b_batchnorm3_gamma is done with shape:  (24,)
i3d_inceptionv11_Mixed_4b_batchnorm3_beta is done with shape:  (24,)
i3d_inceptionv11_Mixed_4b_batchnorm3_running_mean is done with shape:  (24,)
i3d_inceptionv11_Mixed_4b_batchnorm3_running_var is done with shape:  (24,)
i3d_inceptionv11_Mixed_4b_conv4_weight is done with shape:  (64, 24, 3, 3, 3)
i3d_inceptionv11_Mixed_4b_batchnorm4_gamma is done with shape:  (64,)
i3d_inceptionv11_Mixed_4b_batchnorm4_beta is done with shape:  (64,)
i3d_inceptionv11_Mixed_4b_batchnorm4_running_mean is done with shape:  (64,)
i3d_inceptionv11_Mixed_4b_batchnorm4_running_var is done with shape:  (64,)
i3d_inceptionv11_Mixed_4b_conv5_weight is done with shape:  (64, 512, 1, 1, 1)
i3d_inceptionv11_Mixed_4b_batchnorm5_gamma is done with shape:  (64,)
i3d_inceptionv11_Mixed_4b_batchnorm5_beta is done with shape:  (64,)
i3d_inceptionv11_Mixed_4b_batchnorm5_running_mean is done with shape:  (64,)
i3d_inceptionv11_Mixed_4b_batchnorm5_running_var is done with shape:  (64,)
i3d_inceptionv11_Mixed_4c_conv0_weight is done with shape:  (128, 512, 1, 1, 1)
i3d_inceptionv11_Mixed_4c_batchnorm0_gamma is done with shape:  (128,)
i3d_inceptionv11_Mixed_4c_batchnorm0_beta is done with shape:  (128,)
i3d_inceptionv11_Mixed_4c_batchnorm0_running_mean is done with shape:  (128,)
i3d_inceptionv11_Mixed_4c_batchnorm0_running_var is done with shape:  (128,)
i3d_inceptionv11_Mixed_4c_conv1_weight is done with shape:  (128, 512, 1, 1, 1)
i3d_inceptionv11_Mixed_4c_batchnorm1_gamma is done with shape:  (128,)
i3d_inceptionv11_Mixed_4c_batchnorm1_beta is done with shape:  (128,)
i3d_inceptionv11_Mixed_4c_batchnorm1_running_mean is done with shape:  (128,)
i3d_inceptionv11_Mixed_4c_batchnorm1_running_var is done with shape:  (128,)
i3d_inceptionv11_Mixed_4c_conv2_weight is done with shape:  (256, 128, 3, 3, 3)
i3d_inceptionv11_Mixed_4c_batchnorm2_gamma is done with shape:  (256,)
i3d_inceptionv11_Mixed_4c_batchnorm2_beta is done with shape:  (256,)
i3d_inceptionv11_Mixed_4c_batchnorm2_running_mean is done with shape:  (256,)
i3d_inceptionv11_Mixed_4c_batchnorm2_running_var is done with shape:  (256,)
i3d_inceptionv11_Mixed_4c_conv3_weight is done with shape:  (24, 512, 1, 1, 1)
i3d_inceptionv11_Mixed_4c_batchnorm3_gamma is done with shape:  (24,)
i3d_inceptionv11_Mixed_4c_batchnorm3_beta is done with shape:  (24,)
i3d_inceptionv11_Mixed_4c_batchnorm3_running_mean is done with shape:  (24,)
i3d_inceptionv11_Mixed_4c_batchnorm3_running_var is done with shape:  (24,)
i3d_inceptionv11_Mixed_4c_conv4_weight is done with shape:  (64, 24, 3, 3, 3)
i3d_inceptionv11_Mixed_4c_batchnorm4_gamma is done with shape:  (64,)
i3d_inceptionv11_Mixed_4c_batchnorm4_beta is done with shape:  (64,)
i3d_inceptionv11_Mixed_4c_batchnorm4_running_mean is done with shape:  (64,)
i3d_inceptionv11_Mixed_4c_batchnorm4_running_var is done with shape:  (64,)
i3d_inceptionv11_Mixed_4c_conv5_weight is done with shape:  (64, 512, 1, 1, 1)
i3d_inceptionv11_Mixed_4c_batchnorm5_gamma is done with shape:  (64,)
i3d_inceptionv11_Mixed_4c_batchnorm5_beta is done with shape:  (64,)
i3d_inceptionv11_Mixed_4c_batchnorm5_running_mean is done with shape:  (64,)
i3d_inceptionv11_Mixed_4c_batchnorm5_running_var is done with shape:  (64,)
i3d_inceptionv11_Mixed_4d_conv0_weight is done with shape:  (112, 512, 1, 1, 1)
i3d_inceptionv11_Mixed_4d_batchnorm0_gamma is done with shape:  (112,)
i3d_inceptionv11_Mixed_4d_batchnorm0_beta is done with shape:  (112,)
i3d_inceptionv11_Mixed_4d_batchnorm0_running_mean is done with shape:  (112,)
i3d_inceptionv11_Mixed_4d_batchnorm0_running_var is done with shape:  (112,)
i3d_inceptionv11_Mixed_4d_conv1_weight is done with shape:  (144, 512, 1, 1, 1)
i3d_inceptionv11_Mixed_4d_batchnorm1_gamma is done with shape:  (144,)
i3d_inceptionv11_Mixed_4d_batchnorm1_beta is done with shape:  (144,)
i3d_inceptionv11_Mixed_4d_batchnorm1_running_mean is done with shape:  (144,)
i3d_inceptionv11_Mixed_4d_batchnorm1_running_var is done with shape:  (144,)
i3d_inceptionv11_Mixed_4d_conv2_weight is done with shape:  (288, 144, 3, 3, 3)
i3d_inceptionv11_Mixed_4d_batchnorm2_gamma is done with shape:  (288,)
i3d_inceptionv11_Mixed_4d_batchnorm2_beta is done with shape:  (288,)
i3d_inceptionv11_Mixed_4d_batchnorm2_running_mean is done with shape:  (288,)
i3d_inceptionv11_Mixed_4d_batchnorm2_running_var is done with shape:  (288,)
i3d_inceptionv11_Mixed_4d_conv3_weight is done with shape:  (32, 512, 1, 1, 1)
i3d_inceptionv11_Mixed_4d_batchnorm3_gamma is done with shape:  (32,)
i3d_inceptionv11_Mixed_4d_batchnorm3_beta is done with shape:  (32,)
i3d_inceptionv11_Mixed_4d_batchnorm3_running_mean is done with shape:  (32,)
i3d_inceptionv11_Mixed_4d_batchnorm3_running_var is done with shape:  (32,)
i3d_inceptionv11_Mixed_4d_conv4_weight is done with shape:  (64, 32, 3, 3, 3)
i3d_inceptionv11_Mixed_4d_batchnorm4_gamma is done with shape:  (64,)
i3d_inceptionv11_Mixed_4d_batchnorm4_beta is done with shape:  (64,)
i3d_inceptionv11_Mixed_4d_batchnorm4_running_mean is done with shape:  (64,)
i3d_inceptionv11_Mixed_4d_batchnorm4_running_var is done with shape:  (64,)
i3d_inceptionv11_Mixed_4d_conv5_weight is done with shape:  (64, 512, 1, 1, 1)
i3d_inceptionv11_Mixed_4d_batchnorm5_gamma is done with shape:  (64,)
i3d_inceptionv11_Mixed_4d_batchnorm5_beta is done with shape:  (64,)
i3d_inceptionv11_Mixed_4d_batchnorm5_running_mean is done with shape:  (64,)
i3d_inceptionv11_Mixed_4d_batchnorm5_running_var is done with shape:  (64,)
i3d_inceptionv11_Mixed_4e_conv0_weight is done with shape:  (256, 528, 1, 1, 1)
i3d_inceptionv11_Mixed_4e_batchnorm0_gamma is done with shape:  (256,)
i3d_inceptionv11_Mixed_4e_batchnorm0_beta is done with shape:  (256,)
i3d_inceptionv11_Mixed_4e_batchnorm0_running_mean is done with shape:  (256,)
i3d_inceptionv11_Mixed_4e_batchnorm0_running_var is done with shape:  (256,)
i3d_inceptionv11_Mixed_4e_conv1_weight is done with shape:  (160, 528, 1, 1, 1)
i3d_inceptionv11_Mixed_4e_batchnorm1_gamma is done with shape:  (160,)
i3d_inceptionv11_Mixed_4e_batchnorm1_beta is done with shape:  (160,)
i3d_inceptionv11_Mixed_4e_batchnorm1_running_mean is done with shape:  (160,)
i3d_inceptionv11_Mixed_4e_batchnorm1_running_var is done with shape:  (160,)
i3d_inceptionv11_Mixed_4e_conv2_weight is done with shape:  (320, 160, 3, 3, 3)
i3d_inceptionv11_Mixed_4e_batchnorm2_gamma is done with shape:  (320,)
i3d_inceptionv11_Mixed_4e_batchnorm2_beta is done with shape:  (320,)
i3d_inceptionv11_Mixed_4e_batchnorm2_running_mean is done with shape:  (320,)
i3d_inceptionv11_Mixed_4e_batchnorm2_running_var is done with shape:  (320,)
i3d_inceptionv11_Mixed_4e_conv3_weight is done with shape:  (32, 528, 1, 1, 1)
i3d_inceptionv11_Mixed_4e_batchnorm3_gamma is done with shape:  (32,)
i3d_inceptionv11_Mixed_4e_batchnorm3_beta is done with shape:  (32,)
i3d_inceptionv11_Mixed_4e_batchnorm3_running_mean is done with shape:  (32,)
i3d_inceptionv11_Mixed_4e_batchnorm3_running_var is done with shape:  (32,)
i3d_inceptionv11_Mixed_4e_conv4_weight is done with shape:  (128, 32, 3, 3, 3)
i3d_inceptionv11_Mixed_4e_batchnorm4_gamma is done with shape:  (128,)
i3d_inceptionv11_Mixed_4e_batchnorm4_beta is done with shape:  (128,)
i3d_inceptionv11_Mixed_4e_batchnorm4_running_mean is done with shape:  (128,)
i3d_inceptionv11_Mixed_4e_batchnorm4_running_var is done with shape:  (128,)
i3d_inceptionv11_Mixed_4e_conv5_weight is done with shape:  (128, 528, 1, 1, 1)
i3d_inceptionv11_Mixed_4e_batchnorm5_gamma is done with shape:  (128,)
i3d_inceptionv11_Mixed_4e_batchnorm5_beta is done with shape:  (128,)
i3d_inceptionv11_Mixed_4e_batchnorm5_running_mean is done with shape:  (128,)
i3d_inceptionv11_Mixed_4e_batchnorm5_running_var is done with shape:  (128,)
i3d_inceptionv11_Mixed_5a_conv0_weight is done with shape:  (256, 832, 1, 1, 1)
i3d_inceptionv11_Mixed_5a_batchnorm0_gamma is done with shape:  (256,)
i3d_inceptionv11_Mixed_5a_batchnorm0_beta is done with shape:  (256,)
i3d_inceptionv11_Mixed_5a_batchnorm0_running_mean is done with shape:  (256,)
i3d_inceptionv11_Mixed_5a_batchnorm0_running_var is done with shape:  (256,)
i3d_inceptionv11_Mixed_5a_conv1_weight is done with shape:  (160, 832, 1, 1, 1)
i3d_inceptionv11_Mixed_5a_batchnorm1_gamma is done with shape:  (160,)
i3d_inceptionv11_Mixed_5a_batchnorm1_beta is done with shape:  (160,)
i3d_inceptionv11_Mixed_5a_batchnorm1_running_mean is done with shape:  (160,)
i3d_inceptionv11_Mixed_5a_batchnorm1_running_var is done with shape:  (160,)
i3d_inceptionv11_Mixed_5a_conv2_weight is done with shape:  (320, 160, 3, 3, 3)
i3d_inceptionv11_Mixed_5a_batchnorm2_gamma is done with shape:  (320,)
i3d_inceptionv11_Mixed_5a_batchnorm2_beta is done with shape:  (320,)
i3d_inceptionv11_Mixed_5a_batchnorm2_running_mean is done with shape:  (320,)
i3d_inceptionv11_Mixed_5a_batchnorm2_running_var is done with shape:  (320,)
i3d_inceptionv11_Mixed_5a_conv3_weight is done with shape:  (32, 832, 1, 1, 1)
i3d_inceptionv11_Mixed_5a_batchnorm3_gamma is done with shape:  (32,)
i3d_inceptionv11_Mixed_5a_batchnorm3_beta is done with shape:  (32,)
i3d_inceptionv11_Mixed_5a_batchnorm3_running_mean is done with shape:  (32,)
i3d_inceptionv11_Mixed_5a_batchnorm3_running_var is done with shape:  (32,)
i3d_inceptionv11_Mixed_5a_conv4_weight is done with shape:  (128, 32, 3, 3, 3)
i3d_inceptionv11_Mixed_5a_batchnorm4_gamma is done with shape:  (128,)
i3d_inceptionv11_Mixed_5a_batchnorm4_beta is done with shape:  (128,)
i3d_inceptionv11_Mixed_5a_batchnorm4_running_mean is done with shape:  (128,)
i3d_inceptionv11_Mixed_5a_batchnorm4_running_var is done with shape:  (128,)
i3d_inceptionv11_Mixed_5a_conv5_weight is done with shape:  (128, 832, 1, 1, 1)
i3d_inceptionv11_Mixed_5a_batchnorm5_gamma is done with shape:  (128,)
i3d_inceptionv11_Mixed_5a_batchnorm5_beta is done with shape:  (128,)
i3d_inceptionv11_Mixed_5a_batchnorm5_running_mean is done with shape:  (128,)
i3d_inceptionv11_Mixed_5a_batchnorm5_running_var is done with shape:  (128,)
i3d_inceptionv11_Mixed_5b_conv0_weight is done with shape:  (384, 832, 1, 1, 1)
i3d_inceptionv11_Mixed_5b_batchnorm0_gamma is done with shape:  (384,)
i3d_inceptionv11_Mixed_5b_batchnorm0_beta is done with shape:  (384,)
i3d_inceptionv11_Mixed_5b_batchnorm0_running_mean is done with shape:  (384,)
i3d_inceptionv11_Mixed_5b_batchnorm0_running_var is done with shape:  (384,)
i3d_inceptionv11_Mixed_5b_conv1_weight is done with shape:  (192, 832, 1, 1, 1)
i3d_inceptionv11_Mixed_5b_batchnorm1_gamma is done with shape:  (192,)
i3d_inceptionv11_Mixed_5b_batchnorm1_beta is done with shape:  (192,)
i3d_inceptionv11_Mixed_5b_batchnorm1_running_mean is done with shape:  (192,)
i3d_inceptionv11_Mixed_5b_batchnorm1_running_var is done with shape:  (192,)
i3d_inceptionv11_Mixed_5b_conv2_weight is done with shape:  (384, 192, 3, 3, 3)
i3d_inceptionv11_Mixed_5b_batchnorm2_gamma is done with shape:  (384,)
i3d_inceptionv11_Mixed_5b_batchnorm2_beta is done with shape:  (384,)
i3d_inceptionv11_Mixed_5b_batchnorm2_running_mean is done with shape:  (384,)
i3d_inceptionv11_Mixed_5b_batchnorm2_running_var is done with shape:  (384,)
i3d_inceptionv11_Mixed_5b_conv3_weight is done with shape:  (48, 832, 1, 1, 1)
i3d_inceptionv11_Mixed_5b_batchnorm3_gamma is done with shape:  (48,)
i3d_inceptionv11_Mixed_5b_batchnorm3_beta is done with shape:  (48,)
i3d_inceptionv11_Mixed_5b_batchnorm3_running_mean is done with shape:  (48,)
i3d_inceptionv11_Mixed_5b_batchnorm3_running_var is done with shape:  (48,)
i3d_inceptionv11_Mixed_5b_conv4_weight is done with shape:  (128, 48, 3, 3, 3)
i3d_inceptionv11_Mixed_5b_batchnorm4_gamma is done with shape:  (128,)
i3d_inceptionv11_Mixed_5b_batchnorm4_beta is done with shape:  (128,)
i3d_inceptionv11_Mixed_5b_batchnorm4_running_mean is done with shape:  (128,)
i3d_inceptionv11_Mixed_5b_batchnorm4_running_var is done with shape:  (128,)
i3d_inceptionv11_Mixed_5b_conv5_weight is done with shape:  (128, 832, 1, 1, 1)
i3d_inceptionv11_Mixed_5b_batchnorm5_gamma is done with shape:  (128,)
i3d_inceptionv11_Mixed_5b_batchnorm5_beta is done with shape:  (128,)
i3d_inceptionv11_Mixed_5b_batchnorm5_running_mean is done with shape:  (128,)
i3d_inceptionv11_Mixed_5b_batchnorm5_running_var is done with shape:  (128,)
i3d_inceptionv11_dense0_weight is skipped with shape:  (400, 1024)
i3d_inceptionv11_dense0_bias is skipped with shape:  (400,)
I3D_InceptionV1(
  (features): HybridSequential(
    (0): HybridSequential(
      (0): Conv3D(3 -> 64, kernel_size=(7, 7, 7), stride=(2, 2, 2), padding=(3, 3, 3), bias=False)
      (1): BatchNorm(axis=1, eps=0.001, momentum=0.9, fix_gamma=False, use_global_stats=False, in_channels=64)
      (2): Activation(relu)
    )
    (1): MaxPool3D(size=(1, 3, 3), stride=(1, 2, 2), padding=(0, 1, 1), ceil_mode=False, global_pool=False, pool_type=max, layout=NCDHW)
    (2): HybridSequential(
      (0): Conv3D(64 -> 64, kernel_size=(1, 1, 1), stride=(1, 1, 1), bias=False)
      (1): BatchNorm(axis=1, eps=0.001, momentum=0.9, fix_gamma=False, use_global_stats=False, in_channels=64)
      (2): Activation(relu)
    )
    (3): HybridSequential(
      (0): Conv3D(64 -> 192, kernel_size=(3, 3, 3), stride=(1, 1, 1), padding=(1, 1, 1), bias=False)
      (1): BatchNorm(axis=1, eps=0.001, momentum=0.9, fix_gamma=False, use_global_stats=False, in_channels=192)
      (2): Activation(relu)
    )
    (4): MaxPool3D(size=(1, 3, 3), stride=(1, 2, 2), padding=(0, 1, 1), ceil_mode=False, global_pool=False, pool_type=max, layout=NCDHW)
    (5): HybridConcurrent(
      (0): HybridSequential(
        (0): HybridSequential(
          (0): Conv3D(192 -> 64, kernel_size=(1, 1, 1), stride=(1, 1, 1), bias=False)
          (1): BatchNorm(axis=1, eps=0.001, momentum=0.9, fix_gamma=False, use_global_stats=False, in_channels=64)
          (2): Activation(relu)
        )
      )
      (1): HybridSequential(
        (0): HybridSequential(
          (0): Conv3D(192 -> 96, kernel_size=(1, 1, 1), stride=(1, 1, 1), bias=False)
          (1): BatchNorm(axis=1, eps=0.001, momentum=0.9, fix_gamma=False, use_global_stats=False, in_channels=96)
          (2): Activation(relu)
        )
        (1): HybridSequential(
          (0): Conv3D(96 -> 128, kernel_size=(3, 3, 3), stride=(1, 1, 1), padding=(1, 1, 1), bias=False)
          (1): BatchNorm(axis=1, eps=0.001, momentum=0.9, fix_gamma=False, use_global_stats=False, in_channels=128)
          (2): Activation(relu)
        )
      )
      (2): HybridSequential(
        (0): HybridSequential(
          (0): Conv3D(192 -> 16, kernel_size=(1, 1, 1), stride=(1, 1, 1), bias=False)
          (1): BatchNorm(axis=1, eps=0.001, momentum=0.9, fix_gamma=False, use_global_stats=False, in_channels=16)
          (2): Activation(relu)
        )
        (1): HybridSequential(
          (0): Conv3D(16 -> 32, kernel_size=(3, 3, 3), stride=(1, 1, 1), padding=(1, 1, 1), bias=False)
          (1): BatchNorm(axis=1, eps=0.001, momentum=0.9, fix_gamma=False, use_global_stats=False, in_channels=32)
          (2): Activation(relu)
        )
      )
      (3): HybridSequential(
        (0): MaxPool3D(size=(3, 3, 3), stride=(1, 1, 1), padding=(1, 1, 1), ceil_mode=False, global_pool=False, pool_type=max, layout=NCDHW)
        (1): HybridSequential(
          (0): Conv3D(192 -> 32, kernel_size=(1, 1, 1), stride=(1, 1, 1), bias=False)
          (1): BatchNorm(axis=1, eps=0.001, momentum=0.9, fix_gamma=False, use_global_stats=False, in_channels=32)
          (2): Activation(relu)
        )
      )
    )
    (6): HybridConcurrent(
      (0): HybridSequential(
        (0): HybridSequential(
          (0): Conv3D(256 -> 128, kernel_size=(1, 1, 1), stride=(1, 1, 1), bias=False)
          (1): BatchNorm(axis=1, eps=0.001, momentum=0.9, fix_gamma=False, use_global_stats=False, in_channels=128)
          (2): Activation(relu)
        )
      )
      (1): HybridSequential(
        (0): HybridSequential(
          (0): Conv3D(256 -> 128, kernel_size=(1, 1, 1), stride=(1, 1, 1), bias=False)
          (1): BatchNorm(axis=1, eps=0.001, momentum=0.9, fix_gamma=False, use_global_stats=False, in_channels=128)
          (2): Activation(relu)
        )
        (1): HybridSequential(
          (0): Conv3D(128 -> 192, kernel_size=(3, 3, 3), stride=(1, 1, 1), padding=(1, 1, 1), bias=False)
          (1): BatchNorm(axis=1, eps=0.001, momentum=0.9, fix_gamma=False, use_global_stats=False, in_channels=192)
          (2): Activation(relu)
        )
      )
      (2): HybridSequential(
        (0): HybridSequential(
          (0): Conv3D(256 -> 32, kernel_size=(1, 1, 1), stride=(1, 1, 1), bias=False)
          (1): BatchNorm(axis=1, eps=0.001, momentum=0.9, fix_gamma=False, use_global_stats=False, in_channels=32)
          (2): Activation(relu)
        )
        (1): HybridSequential(
          (0): Conv3D(32 -> 96, kernel_size=(3, 3, 3), stride=(1, 1, 1), padding=(1, 1, 1), bias=False)
          (1): BatchNorm(axis=1, eps=0.001, momentum=0.9, fix_gamma=False, use_global_stats=False, in_channels=96)
          (2): Activation(relu)
        )
      )
      (3): HybridSequential(
        (0): MaxPool3D(size=(3, 3, 3), stride=(1, 1, 1), padding=(1, 1, 1), ceil_mode=False, global_pool=False, pool_type=max, layout=NCDHW)
        (1): HybridSequential(
          (0): Conv3D(256 -> 64, kernel_size=(1, 1, 1), stride=(1, 1, 1), bias=False)
          (1): BatchNorm(axis=1, eps=0.001, momentum=0.9, fix_gamma=False, use_global_stats=False, in_channels=64)
          (2): Activation(relu)
        )
      )
    )
    (7): MaxPool3D(size=(3, 3, 3), stride=(2, 2, 2), padding=(1, 1, 1), ceil_mode=False, global_pool=False, pool_type=max, layout=NCDHW)
    (8): HybridConcurrent(
      (0): HybridSequential(
        (0): HybridSequential(
          (0): Conv3D(480 -> 192, kernel_size=(1, 1, 1), stride=(1, 1, 1), bias=False)
          (1): BatchNorm(axis=1, eps=0.001, momentum=0.9, fix_gamma=False, use_global_stats=False, in_channels=192)
          (2): Activation(relu)
        )
      )
      (1): HybridSequential(
        (0): HybridSequential(
          (0): Conv3D(480 -> 96, kernel_size=(1, 1, 1), stride=(1, 1, 1), bias=False)
          (1): BatchNorm(axis=1, eps=0.001, momentum=0.9, fix_gamma=False, use_global_stats=False, in_channels=96)
          (2): Activation(relu)
        )
        (1): HybridSequential(
          (0): Conv3D(96 -> 208, kernel_size=(3, 3, 3), stride=(1, 1, 1), padding=(1, 1, 1), bias=False)
          (1): BatchNorm(axis=1, eps=0.001, momentum=0.9, fix_gamma=False, use_global_stats=False, in_channels=208)
          (2): Activation(relu)
        )
      )
      (2): HybridSequential(
        (0): HybridSequential(
          (0): Conv3D(480 -> 16, kernel_size=(1, 1, 1), stride=(1, 1, 1), bias=False)
          (1): BatchNorm(axis=1, eps=0.001, momentum=0.9, fix_gamma=False, use_global_stats=False, in_channels=16)
          (2): Activation(relu)
        )
        (1): HybridSequential(
          (0): Conv3D(16 -> 48, kernel_size=(3, 3, 3), stride=(1, 1, 1), padding=(1, 1, 1), bias=False)
          (1): BatchNorm(axis=1, eps=0.001, momentum=0.9, fix_gamma=False, use_global_stats=False, in_channels=48)
          (2): Activation(relu)
        )
      )
      (3): HybridSequential(
        (0): MaxPool3D(size=(3, 3, 3), stride=(1, 1, 1), padding=(1, 1, 1), ceil_mode=False, global_pool=False, pool_type=max, layout=NCDHW)
        (1): HybridSequential(
          (0): Conv3D(480 -> 64, kernel_size=(1, 1, 1), stride=(1, 1, 1), bias=False)
          (1): BatchNorm(axis=1, eps=0.001, momentum=0.9, fix_gamma=False, use_global_stats=False, in_channels=64)
          (2): Activation(relu)
        )
      )
    )
    (9): HybridConcurrent(
      (0): HybridSequential(
        (0): HybridSequential(
          (0): Conv3D(512 -> 160, kernel_size=(1, 1, 1), stride=(1, 1, 1), bias=False)
          (1): BatchNorm(axis=1, eps=0.001, momentum=0.9, fix_gamma=False, use_global_stats=False, in_channels=160)
          (2): Activation(relu)
        )
      )
      (1): HybridSequential(
        (0): HybridSequential(
          (0): Conv3D(512 -> 112, kernel_size=(1, 1, 1), stride=(1, 1, 1), bias=False)
          (1): BatchNorm(axis=1, eps=0.001, momentum=0.9, fix_gamma=False, use_global_stats=False, in_channels=112)
          (2): Activation(relu)
        )
        (1): HybridSequential(
          (0): Conv3D(112 -> 224, kernel_size=(3, 3, 3), stride=(1, 1, 1), padding=(1, 1, 1), bias=False)
          (1): BatchNorm(axis=1, eps=0.001, momentum=0.9, fix_gamma=False, use_global_stats=False, in_channels=224)
          (2): Activation(relu)
        )
      )
      (2): HybridSequential(
        (0): HybridSequential(
          (0): Conv3D(512 -> 24, kernel_size=(1, 1, 1), stride=(1, 1, 1), bias=False)
          (1): BatchNorm(axis=1, eps=0.001, momentum=0.9, fix_gamma=False, use_global_stats=False, in_channels=24)
          (2): Activation(relu)
        )
        (1): HybridSequential(
          (0): Conv3D(24 -> 64, kernel_size=(3, 3, 3), stride=(1, 1, 1), padding=(1, 1, 1), bias=False)
          (1): BatchNorm(axis=1, eps=0.001, momentum=0.9, fix_gamma=False, use_global_stats=False, in_channels=64)
          (2): Activation(relu)
        )
      )
      (3): HybridSequential(
        (0): MaxPool3D(size=(3, 3, 3), stride=(1, 1, 1), padding=(1, 1, 1), ceil_mode=False, global_pool=False, pool_type=max, layout=NCDHW)
        (1): HybridSequential(
          (0): Conv3D(512 -> 64, kernel_size=(1, 1, 1), stride=(1, 1, 1), bias=False)
          (1): BatchNorm(axis=1, eps=0.001, momentum=0.9, fix_gamma=False, use_global_stats=False, in_channels=64)
          (2): Activation(relu)
        )
      )
    )
    (10): HybridConcurrent(
      (0): HybridSequential(
        (0): HybridSequential(
          (0): Conv3D(512 -> 128, kernel_size=(1, 1, 1), stride=(1, 1, 1), bias=False)
          (1): BatchNorm(axis=1, eps=0.001, momentum=0.9, fix_gamma=False, use_global_stats=False, in_channels=128)
          (2): Activation(relu)
        )
      )
      (1): HybridSequential(
        (0): HybridSequential(
          (0): Conv3D(512 -> 128, kernel_size=(1, 1, 1), stride=(1, 1, 1), bias=False)
          (1): BatchNorm(axis=1, eps=0.001, momentum=0.9, fix_gamma=False, use_global_stats=False, in_channels=128)
          (2): Activation(relu)
        )
        (1): HybridSequential(
          (0): Conv3D(128 -> 256, kernel_size=(3, 3, 3), stride=(1, 1, 1), padding=(1, 1, 1), bias=False)
          (1): BatchNorm(axis=1, eps=0.001, momentum=0.9, fix_gamma=False, use_global_stats=False, in_channels=256)
          (2): Activation(relu)
        )
      )
      (2): HybridSequential(
        (0): HybridSequential(
          (0): Conv3D(512 -> 24, kernel_size=(1, 1, 1), stride=(1, 1, 1), bias=False)
          (1): BatchNorm(axis=1, eps=0.001, momentum=0.9, fix_gamma=False, use_global_stats=False, in_channels=24)
          (2): Activation(relu)
        )
        (1): HybridSequential(
          (0): Conv3D(24 -> 64, kernel_size=(3, 3, 3), stride=(1, 1, 1), padding=(1, 1, 1), bias=False)
          (1): BatchNorm(axis=1, eps=0.001, momentum=0.9, fix_gamma=False, use_global_stats=False, in_channels=64)
          (2): Activation(relu)
        )
      )
      (3): HybridSequential(
        (0): MaxPool3D(size=(3, 3, 3), stride=(1, 1, 1), padding=(1, 1, 1), ceil_mode=False, global_pool=False, pool_type=max, layout=NCDHW)
        (1): HybridSequential(
          (0): Conv3D(512 -> 64, kernel_size=(1, 1, 1), stride=(1, 1, 1), bias=False)
          (1): BatchNorm(axis=1, eps=0.001, momentum=0.9, fix_gamma=False, use_global_stats=False, in_channels=64)
          (2): Activation(relu)
        )
      )
    )
    (11): HybridConcurrent(
      (0): HybridSequential(
        (0): HybridSequential(
          (0): Conv3D(512 -> 112, kernel_size=(1, 1, 1), stride=(1, 1, 1), bias=False)
          (1): BatchNorm(axis=1, eps=0.001, momentum=0.9, fix_gamma=False, use_global_stats=False, in_channels=112)
          (2): Activation(relu)
        )
      )
      (1): HybridSequential(
        (0): HybridSequential(
          (0): Conv3D(512 -> 144, kernel_size=(1, 1, 1), stride=(1, 1, 1), bias=False)
          (1): BatchNorm(axis=1, eps=0.001, momentum=0.9, fix_gamma=False, use_global_stats=False, in_channels=144)
          (2): Activation(relu)
        )
        (1): HybridSequential(
          (0): Conv3D(144 -> 288, kernel_size=(3, 3, 3), stride=(1, 1, 1), padding=(1, 1, 1), bias=False)
          (1): BatchNorm(axis=1, eps=0.001, momentum=0.9, fix_gamma=False, use_global_stats=False, in_channels=288)
          (2): Activation(relu)
        )
      )
      (2): HybridSequential(
        (0): HybridSequential(
          (0): Conv3D(512 -> 32, kernel_size=(1, 1, 1), stride=(1, 1, 1), bias=False)
          (1): BatchNorm(axis=1, eps=0.001, momentum=0.9, fix_gamma=False, use_global_stats=False, in_channels=32)
          (2): Activation(relu)
        )
        (1): HybridSequential(
          (0): Conv3D(32 -> 64, kernel_size=(3, 3, 3), stride=(1, 1, 1), padding=(1, 1, 1), bias=False)
          (1): BatchNorm(axis=1, eps=0.001, momentum=0.9, fix_gamma=False, use_global_stats=False, in_channels=64)
          (2): Activation(relu)
        )
      )
      (3): HybridSequential(
        (0): MaxPool3D(size=(3, 3, 3), stride=(1, 1, 1), padding=(1, 1, 1), ceil_mode=False, global_pool=False, pool_type=max, layout=NCDHW)
        (1): HybridSequential(
          (0): Conv3D(512 -> 64, kernel_size=(1, 1, 1), stride=(1, 1, 1), bias=False)
          (1): BatchNorm(axis=1, eps=0.001, momentum=0.9, fix_gamma=False, use_global_stats=False, in_channels=64)
          (2): Activation(relu)
        )
      )
    )
    (12): HybridConcurrent(
      (0): HybridSequential(
        (0): HybridSequential(
          (0): Conv3D(528 -> 256, kernel_size=(1, 1, 1), stride=(1, 1, 1), bias=False)
          (1): BatchNorm(axis=1, eps=0.001, momentum=0.9, fix_gamma=False, use_global_stats=False, in_channels=256)
          (2): Activation(relu)
        )
      )
      (1): HybridSequential(
        (0): HybridSequential(
          (0): Conv3D(528 -> 160, kernel_size=(1, 1, 1), stride=(1, 1, 1), bias=False)
          (1): BatchNorm(axis=1, eps=0.001, momentum=0.9, fix_gamma=False, use_global_stats=False, in_channels=160)
          (2): Activation(relu)
        )
        (1): HybridSequential(
          (0): Conv3D(160 -> 320, kernel_size=(3, 3, 3), stride=(1, 1, 1), padding=(1, 1, 1), bias=False)
          (1): BatchNorm(axis=1, eps=0.001, momentum=0.9, fix_gamma=False, use_global_stats=False, in_channels=320)
          (2): Activation(relu)
        )
      )
      (2): HybridSequential(
        (0): HybridSequential(
          (0): Conv3D(528 -> 32, kernel_size=(1, 1, 1), stride=(1, 1, 1), bias=False)
          (1): BatchNorm(axis=1, eps=0.001, momentum=0.9, fix_gamma=False, use_global_stats=False, in_channels=32)
          (2): Activation(relu)
        )
        (1): HybridSequential(
          (0): Conv3D(32 -> 128, kernel_size=(3, 3, 3), stride=(1, 1, 1), padding=(1, 1, 1), bias=False)
          (1): BatchNorm(axis=1, eps=0.001, momentum=0.9, fix_gamma=False, use_global_stats=False, in_channels=128)
          (2): Activation(relu)
        )
      )
      (3): HybridSequential(
        (0): MaxPool3D(size=(3, 3, 3), stride=(1, 1, 1), padding=(1, 1, 1), ceil_mode=False, global_pool=False, pool_type=max, layout=NCDHW)
        (1): HybridSequential(
          (0): Conv3D(528 -> 128, kernel_size=(1, 1, 1), stride=(1, 1, 1), bias=False)
          (1): BatchNorm(axis=1, eps=0.001, momentum=0.9, fix_gamma=False, use_global_stats=False, in_channels=128)
          (2): Activation(relu)
        )
      )
    )
    (13): MaxPool3D(size=(2, 2, 2), stride=(2, 2, 2), padding=(0, 0, 0), ceil_mode=False, global_pool=False, pool_type=max, layout=NCDHW)
    (14): HybridConcurrent(
      (0): HybridSequential(
        (0): HybridSequential(
          (0): Conv3D(832 -> 256, kernel_size=(1, 1, 1), stride=(1, 1, 1), bias=False)
          (1): BatchNorm(axis=1, eps=0.001, momentum=0.9, fix_gamma=False, use_global_stats=False, in_channels=256)
          (2): Activation(relu)
        )
      )
      (1): HybridSequential(
        (0): HybridSequential(
          (0): Conv3D(832 -> 160, kernel_size=(1, 1, 1), stride=(1, 1, 1), bias=False)
          (1): BatchNorm(axis=1, eps=0.001, momentum=0.9, fix_gamma=False, use_global_stats=False, in_channels=160)
          (2): Activation(relu)
        )
        (1): HybridSequential(
          (0): Conv3D(160 -> 320, kernel_size=(3, 3, 3), stride=(1, 1, 1), padding=(1, 1, 1), bias=False)
          (1): BatchNorm(axis=1, eps=0.001, momentum=0.9, fix_gamma=False, use_global_stats=False, in_channels=320)
          (2): Activation(relu)
        )
      )
      (2): HybridSequential(
        (0): HybridSequential(
          (0): Conv3D(832 -> 32, kernel_size=(1, 1, 1), stride=(1, 1, 1), bias=False)
          (1): BatchNorm(axis=1, eps=0.001, momentum=0.9, fix_gamma=False, use_global_stats=False, in_channels=32)
          (2): Activation(relu)
        )
        (1): HybridSequential(
          (0): Conv3D(32 -> 128, kernel_size=(3, 3, 3), stride=(1, 1, 1), padding=(1, 1, 1), bias=False)
          (1): BatchNorm(axis=1, eps=0.001, momentum=0.9, fix_gamma=False, use_global_stats=False, in_channels=128)
          (2): Activation(relu)
        )
      )
      (3): HybridSequential(
        (0): MaxPool3D(size=(3, 3, 3), stride=(1, 1, 1), padding=(1, 1, 1), ceil_mode=False, global_pool=False, pool_type=max, layout=NCDHW)
        (1): HybridSequential(
          (0): Conv3D(832 -> 128, kernel_size=(1, 1, 1), stride=(1, 1, 1), bias=False)
          (1): BatchNorm(axis=1, eps=0.001, momentum=0.9, fix_gamma=False, use_global_stats=False, in_channels=128)
          (2): Activation(relu)
        )
      )
    )
    (15): HybridConcurrent(
      (0): HybridSequential(
        (0): HybridSequential(
          (0): Conv3D(832 -> 384, kernel_size=(1, 1, 1), stride=(1, 1, 1), bias=False)
          (1): BatchNorm(axis=1, eps=0.001, momentum=0.9, fix_gamma=False, use_global_stats=False, in_channels=384)
          (2): Activation(relu)
        )
      )
      (1): HybridSequential(
        (0): HybridSequential(
          (0): Conv3D(832 -> 192, kernel_size=(1, 1, 1), stride=(1, 1, 1), bias=False)
          (1): BatchNorm(axis=1, eps=0.001, momentum=0.9, fix_gamma=False, use_global_stats=False, in_channels=192)
          (2): Activation(relu)
        )
        (1): HybridSequential(
          (0): Conv3D(192 -> 384, kernel_size=(3, 3, 3), stride=(1, 1, 1), padding=(1, 1, 1), bias=False)
          (1): BatchNorm(axis=1, eps=0.001, momentum=0.9, fix_gamma=False, use_global_stats=False, in_channels=384)
          (2): Activation(relu)
        )
      )
      (2): HybridSequential(
        (0): HybridSequential(
          (0): Conv3D(832 -> 48, kernel_size=(1, 1, 1), stride=(1, 1, 1), bias=False)
          (1): BatchNorm(axis=1, eps=0.001, momentum=0.9, fix_gamma=False, use_global_stats=False, in_channels=48)
          (2): Activation(relu)
        )
        (1): HybridSequential(
          (0): Conv3D(48 -> 128, kernel_size=(3, 3, 3), stride=(1, 1, 1), padding=(1, 1, 1), bias=False)
          (1): BatchNorm(axis=1, eps=0.001, momentum=0.9, fix_gamma=False, use_global_stats=False, in_channels=128)
          (2): Activation(relu)
        )
      )
      (3): HybridSequential(
        (0): MaxPool3D(size=(3, 3, 3), stride=(1, 1, 1), padding=(1, 1, 1), ceil_mode=False, global_pool=False, pool_type=max, layout=NCDHW)
        (1): HybridSequential(
          (0): Conv3D(832 -> 128, kernel_size=(1, 1, 1), stride=(1, 1, 1), bias=False)
          (1): BatchNorm(axis=1, eps=0.001, momentum=0.9, fix_gamma=False, use_global_stats=False, in_channels=128)
          (2): Activation(relu)
        )
      )
    )
    (16): GlobalAvgPool3D(size=(1, 1, 1), stride=(1, 1, 1), padding=(0, 0, 0), ceil_mode=True, global_pool=True, pool_type=avg, layout=NCDHW)
  )
  (head): HybridSequential(
    (0): Dropout(p = 0.5, axes=())
    (1): Dense(1024 -> 400, linear)
  )
  (output): Dense(1024 -> 400, linear)
)

Data Augmentation and Data Loader

Data augmentation for video is different from image. For example, if you want to randomly crop a video sequence, you need to make sure all the video frames in this sequence undergo the same cropping process. We provide a new set of transformation functions, working with multiple images. Please checkout the video.py for more details. Most video data augmentation strategies used here are introduced in [Wang15].

transform_train = transforms.Compose([
    # Fix the input video frames size as 256×340 and randomly sample the cropping width and height from
    # {256,224,192,168}. After that, resize the cropped regions to 224 × 224.
    video.VideoMultiScaleCrop(size=(224, 224), scale_ratios=[1.0, 0.875, 0.75, 0.66]),
    # Randomly flip the video frames horizontally
    video.VideoRandomHorizontalFlip(),
    # Transpose the video frames from height*width*num_channels to num_channels*height*width
    # and map values from [0, 255] to [0,1]
    video.VideoToTensor(),
    # Normalize the video frames with mean and standard deviation calculated across all images
    video.VideoNormalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])
])

With the transform functions, we can define data loaders for our training datasets.

# Batch Size for Each GPU
per_device_batch_size = 5
# Number of data loader workers
num_workers = 8
# Calculate effective total batch size
batch_size = per_device_batch_size * num_gpus

# Set train=True for training the model.
# ``new_length`` indicates the number of frames we use as input.
# ``new_step`` indicates we skip one frame to sample the input data.
train_dataset = Kinetics400(train=True, new_length=32, new_step=2, transform=transform_train)
print('Load %d training samples.' % len(train_dataset))
train_data = gluon.data.DataLoader(train_dataset, batch_size=batch_size,
                                   shuffle=True, num_workers=num_workers)

Out:

Load 375 training samples.

Optimizer, Loss and Metric

# Learning rate decay factor
lr_decay = 0.1
# Epochs where learning rate decays
lr_decay_epoch = [40, 80, 100]

# Stochastic gradient descent
optimizer = 'sgd'
# Set parameters
optimizer_params = {'learning_rate': 0.01, 'wd': 0.0001, 'momentum': 0.9}

# Define our trainer for net
trainer = gluon.Trainer(net.collect_params(), optimizer, optimizer_params)

In order to optimize our model, we need a loss function. For classification tasks, we usually use softmax cross entropy as the loss function.

For simplicity, we use accuracy as the metric to monitor our training process. Besides, we record metric values, and will print them at the end of training.

Training

After all the preparations, we can finally start training! Following is the script.

Note

In order to finish the tutorial quickly, we only train for 3 epochs on a tiny subset of Kinetics400, and 100 iterations per epoch. In your experiments, we recommend setting epochs=100 for the full Kinetics400 dataset.

epochs = 3
lr_decay_count = 0

for epoch in range(epochs):
    tic = time.time()
    train_metric.reset()
    train_loss = 0

    # Learning rate decay
    if epoch == lr_decay_epoch[lr_decay_count]:
        trainer.set_learning_rate(trainer.learning_rate*lr_decay)
        lr_decay_count += 1

    # Loop through each batch of training data
    for i, batch in enumerate(train_data):
        # Extract data and label
        data = split_and_load(batch[0], ctx_list=ctx, batch_axis=0)
        label = split_and_load(batch[1], ctx_list=ctx, batch_axis=0)

        # AutoGrad
        with ag.record():
            output = []
            for _, X in enumerate(data):
                X = X.reshape((-1,) + X.shape[2:])
                pred = net(X)
                output.append(pred)
            loss = [loss_fn(yhat, y) for yhat, y in zip(output, label)]

        # Backpropagation
        for l in loss:
            l.backward()

        # Optimize
        trainer.step(batch_size)

        # Update metrics
        train_loss += sum([l.mean().asscalar() for l in loss])
        train_metric.update(label, output)

        if i == 100:
            break

    name, acc = train_metric.get()

    # Update history and print metrics
    train_history.update([acc])
    print('[Epoch %d] train=%f loss=%f time: %f' %
        (epoch, acc, train_loss / (i+1), time.time()-tic))

# We can plot the metric scores with:
train_history.plot()
../../_images/sphx_glr_dive_deep_i3d_kinetics400_001.png

Out:

[Epoch 0] train=0.000000 loss=6.190424 time: 67.080059
[Epoch 1] train=0.000000 loss=6.000474 time: 47.345157
[Epoch 2] train=0.000000 loss=5.996106 time: 48.056979

Due to the tiny subset, the accuracy number is quite low. You can Start Training Now on the full Kinetics400 dataset.

If you would like to explore more recent models (e.g., SlowFast), feel free to read the next tutorial on SlowFast.

References

Wang15

Limin Wang, Yuanjun Xiong, Zhe Wang, and Yu Qiao. “Towards Good Practices for Very Deep Two-Stream ConvNets.” arXiv preprint arXiv:1507.02159 (2015).

Total running time of the script: ( 2 minutes 44.355 seconds)

Gallery generated by Sphinx-Gallery