def temporal_convs_linear(n_nodes, conv_len, n_classes, n_feat, max_len,
causal=False, loss='categorical_crossentropy',
optimizer='adam', return_param_str=False):
""" Used in paper:
Segmental Spatiotemporal CNNs for Fine-grained Action Segmentation
Lea et al. ECCV 2016
Note: Spatial dropout was not used in the original paper.
It tends to improve performance a little.
"""
inputs = Input(shape=(max_len,n_feat))
if causal: model = ZeroPadding1D((conv_len//2,0))(model)
model = Convolution1D(n_nodes, conv_len, input_dim=n_feat, input_length=max_len, border_mode='same', activation='relu')(inputs)
if causal: model = Cropping1D((0,conv_len//2))(model)
model = SpatialDropout1D(0.3)(model)
model = TimeDistributed(Dense(n_classes, activation="softmax" ))(model)
model = Model(input=inputs, output=model)
model.compile(loss=loss, optimizer=optimizer, sample_weight_mode="temporal")
if return_param_str:
param_str = "tConv_C{}".format(conv_len)
if causal:
param_str += "_causal"
return model, param_str
else:
return model
tf_models.py 文件源码
python
阅读 23
收藏 0
点赞 0
评论 0
评论列表
文章目录