1. 程式人生 > >tensorflow中 rnn.dynamic_cnn與rnn.static_cnn的區別

tensorflow中 rnn.dynamic_cnn與rnn.static_cnn的區別

使用上區別

# @rnn.static_cnn
#    input: a num_step-length list of tensors with shape (batch,embed_size)
#    output: 
#       outputs: a num_step-length list of tensors whose shape is (batch,state_size),
#                which is the last layer output of each time_step/num_step
#       stats: a num_layer-length tuple with shape of its each item (batch,state_size),
# which is every layer output of the last time_step # # @rnn.dynamic_cnn # input: a tensor with shape (batch,num_step,embed_size)) # output: # outputs: a tensor with shape (batch,num_step,state_size), # which is the last layer output of each time_step/num_step
# stats: a num_layer-length tuple with shape of its each item (batch,state_size), # which is every layer output of the last time_step

執行上的區別

# @rnn.dynamic_cnn:
#	the time_step of different batch can be different,
#	which means the rnn will stop when time arrives at time_step
#	and it runs faster than static_cnn
# @rnn.static_cnn: # the time_step of different batch must be same.