L2 = _shared(0)


### useless fake, but DataLoader_with_skeleton_normalisation would require that
x_skeleton = ndtensor(len(tr._skeleon_in_shape))(name = 'x_skeleton') # video input
x_skeleton_ = _shared(empty(tr._skeleon_in_shape))

# load the skeleton normalisation --Lio didn't normalise video input, but should we?
import cPickle
f = open('CNN_normalization.pkl','rb')
CNN_normalization = cPickle.load(f)
Mean_CNN = CNN_normalization ['Mean_CNN']
Std_CNN = CNN_normalization['Std_CNN']

# customized data loader for both video module and skeleton module
loader = DataLoader_with_skeleton_normalisation(src, tr.batch_size, Mean_CNN, Std_CNN) # Lio changed it to read from HDF5 files

####################################################################
# 3DCNN for video module
#################################################################### 
# we load the CNN parameteres here
video_cnn = conv3d_chalearn(x, use, lr, batch, net, reg, drop, mom, tr, res_dir)

#####################################################################
# fuse the ConvNet output with skeleton output  -- need to change here
######################################################################  
out = video_cnn.out
# some activation inspection
insp =  []
for insp_temp in video_cnn.insp:    insp.append(insp_temp)
insp = T.stack(insp)
### useless fake, but DataLoader_with_skeleton_normalisation would require that
x_skeleton = ndtensor(len(tr._skeleon_in_shape))(
    name='x_skeleton')  # video input
x_skeleton_ = _shared(empty(tr._skeleon_in_shape))

# load the skeleton normalisation --Lio didn't normalise video input, but should we?
import cPickle
f = open('CNN_normalization.pkl', 'rb')
CNN_normalization = cPickle.load(f)
Mean_CNN = CNN_normalization['Mean_CNN']
Std_CNN = CNN_normalization['Std_CNN']

# customized data loader for both video module and skeleton module
loader = DataLoader_with_skeleton_normalisation(
    src, tr.batch_size, Mean_CNN,
    Std_CNN)  # Lio changed it to read from HDF5 files

####################################################################
# 3DCNN for video module
####################################################################
#if u have already trained the network before, the might pause for some reason, u can load the updated paramters
# we load the CNN parameteres here
#use.load = True
#load_path = '/home/zhiquan/fancy/meterials/chalearn2014_fancy_data/result_temp/3dcnn/try/70.9% 2018.05.05.02.28.21/'
#video_cnn = conv3d_chalearn(x, use, lr, batch, net, reg, drop, mom, tr, res_dir,load_path)
video_cnn = conv3d_chalearn(x, use, lr, batch, net, reg, drop, mom, tr,
                            res_dir)

#####################################################################
# fuse the ConvNet output with skeleton output  -- need to change here