示例#1
0
    def __init__(self):
        super(Model, self).__init__()

        # some configurations for the model
        n_tc_timesteps = config.cfg.MODEL.N_TC_TIMESTEPS  #32
        backbone_name = config.cfg.MODEL.BACKBONE_CNN  #'i3d_pytorch_charades_rgb'
        feature_name = config.cfg.MODEL.BACKBONE_FEATURE  #'mixed_5c'
        n_tc_layers = config.cfg.MODEL.N_TC_LAYERS  #2
        n_classes = config.cfg.MODEL.N_CLASSES  #157
        is_dilated = config.cfg.MODEL.MULTISCALE_TYPE  #采用的多核策略类型'ks'
        OutputActivation = Sigmoid if config.cfg.MODEL.CLASSIFICATION_TYPE == 'ml' else LogSoftmax
        n_channels_in, channel_h, channel_w = utils.get_model_feat_maps_info(
            backbone_name, feature_name)  #1024, 7, 7
        n_groups = int(n_channels_in / 128.0)  #8

        input_shape = (None, n_channels_in, n_tc_timesteps, channel_h,
                       channel_w
                       )  # (None, C, T, H, W),(None, 1024, 32, 7, 7)其中T是自己设定的
        self._input_shape = input_shape  #(None, 1024, 32, 7, 7)

        # define 4 layers of timeception
        self.timeception = timeception_pytorch.Timeception(
            input_shape, n_tc_layers, n_groups, is_dilated)

        # get number of output channels after timeception
        n_channels_in = self.timeception.n_channels_out

        # define layers for classifier
        self.do1 = Dropout(0.5)
        self.l1 = Linear(n_channels_in, 512)
        self.bn1 = BatchNorm1d(512)
        self.ac1 = LeakyReLU(0.2)
        self.do2 = Dropout(0.25)
        self.l2 = Linear(512, n_classes)
        self.ac2 = OutputActivation()
示例#2
0
    def __init__(self):
        super(Model, self).__init__()

        # some configurations for the model
        n_tc_timesteps = config.cfg.MODEL.N_TC_TIMESTEPS  # 输入到timeception的timesteps
        backbone_name = config.cfg.MODEL.BACKBONE_CNN
        feature_name = config.cfg.MODEL.BACKBONE_FEATURE
        n_tc_layers = config.cfg.MODEL.N_TC_LAYERS  # timeception的层数
        n_classes = config.cfg.MODEL.N_CLASSES  # 157
        is_dilated = config.cfg.MODEL.MULTISCALE_TYPE  # 多尺度的类型(空洞卷积/多尺度卷积核)
        OutputActivation = Sigmoid if config.cfg.MODEL.CLASSIFICATION_TYPE == 'ml' else LogSoftmax
        n_channels_in, channel_h, channel_w = utils.get_model_feat_maps_info(
            backbone_name, feature_name)
        n_groups = int(n_channels_in / 128.0)  # groups的数量

        # timeception层的输入shape
        input_shape = (None, n_channels_in, n_tc_timesteps, channel_h,
                       channel_w)  # (C, T, H, W)
        self._input_shape = input_shape

        # define 4 layers of timeception
        self.timeception = timeception_pytorch.Timeception(
            input_shape, n_tc_layers, n_groups, is_dilated)  # (C, T, H, W)

        # get number of output channels after timeception
        n_channels_in = self.timeception.n_channels_out

        # define layers for classifier
        self.do1 = Dropout(0.5)
        self.l1 = Linear(n_channels_in, 512)
        self.bn1 = BatchNorm1d(512)
        self.ac1 = LeakyReLU(0.2)  #negative_slope:控制负斜率的角度,默认等于0.01
        self.do2 = Dropout(0.25)
        self.l2 = Linear(512, n_classes)
        self.ac2 = OutputActivation()
示例#3
0
import numpy as np
import torch as T
from nets import timeception_pytorch

# i3d first input layer has shape (10, 3, 36, 224, 224)
# (batch_size, channel, time, height, width)

# define input tensor (from i3d last layer before logic)
input = T.tensor(np.zeros((10, 1024, 5, 7, 7)), dtype=T.float32)

# define 4 layers of timeception
module = timeception_pytorch.Timeception(input.size(), n_layers=2)

# feedforward the input to the timeception layers
tensor = module(input)

# the output is (10, 1600, 1, 7, 7)
print(tensor.size())