- dim_proj:表示feature的種類個數
- validFreq:表示多少次更新之後計算validation error
- saveFreq:每次更新saveFreq的時候保存參數,表示保存參數的次數
- maxlen:一般應該是和模態數相等
- valid_batch_size:測試集的batch_size,一定要小於測試集
- modal_costs:一維矩陣,個數是模態數
def train_lstm(
dim_proj=72, # word embeding dimension and LSTM number of hidden units.
patience=15, # Number of epoch to wait before early stop if no progress
max_epochs=5000, # The maximum number of epoch to run
dispFreq=10, # Display to stdout the training progress every N updates
decay_c=0., # Weight decay for the classifier applied to the U weights.
lrate=0.01, # Learning rate for sgd (not used for adadelta and rmsprop)
optimizer=adadelta, # sgd, adadelta and rmsprop available, sgd very hard to use, not recommanded (probably need momentum and decaying learning rate).
# optimizer = sgd,
encoder='lstm', # TODO: can be removed must be lstm.
saveto='lstm_model_best.npz', # The best model will be saved there
validFreq=10, # Compute the validation error after this number of update.
saveFreq=10, # Save the parameters after every saveFreq updates
maxlen=2, # Sequence longer then this get ignored
batch_size=64, # The batch size during training.
valid_batch_size=50, # The batch size used for validation/test set.
dataset=datanamee,
modal_costs = [0.1, 0.1] ,# the cost for each modal
# model_lens = model_len,
# Parameter for extra option
noise_std=0.,
use_dropout=True, # if False slightly faster, but worst test error
# This frequently need a bigger model.
reload_model=None, # Path to a saved model we want to start from.
test_size=-1, # If >0, we keep only this number of test example.
max_costs = 50, # max cost for each instance to use
):
- recyl_maxlen:模態數
#主程序
if __name__ == '__main__':
# See function train for all possible parameter and there definition.
recyl_maxlen = 2 # the max madal can been used for one instance
train_lstm(
max_epochs=300,
test_size=100,
)