コード例 #1
0
def train_lstm_anger():
    vocab_size, trainds, valds, testds, traindl, valdl, testdl = load_uncased_data(
        'anger')

    final_stats_anger = []
    for dropout in [0.1, 0.2, 0.3, 0.4, 0.5]:
        for hidden_size in [25, 50, 75, 100, 125, 150, 175, 200]:
            for lr in [1e-1, 1e-2, 1e-3, 1e-4, 1e-5, 1e-6]:
                model = LSTMClassifier(
                    vocab_size,
                    200,
                    hidden_size,
                    4,
                    trainds.fields['Clean_Tweet'].vocab.vectors,
                    dropout=dropout,
                    bidirectional=False)
                training_stats = train(model,
                                       traindl,
                                       valdl,
                                       lr=lr,
                                       hidden_size=hidden_size,
                                       dropout=dropout)
                final_stats_anger.extend(training_stats)
    pd.DataFrame(final_stats_anger).to_csv(
        './data/models/lstm/results/anger.csv')
コード例 #2
0
def train_bilstm_sadness():
  vocab_size, trainds, valds, testds, traindl, valdl, testdl = load_uncased_data('sadness')
  final_stats_sadness = []
  for dropout in [0.1, 0.2, 0.3, 0.4, 0.5]:
    for hidden_size in [32, 64, 96, 128]:
      for lr in [1e-1, 1e-2, 1e-3, 1e-4, 1e-5, 1e-6]:
        model = LSTMClassifier(
          vocab_size, 
          200, 
          hidden_size, 
          4, 
          trainds.fields['Clean_Tweet'].vocab.vectors,
          dropout=dropout,
          bidirectional=False
        )
        training_stats = train(model, traindl, valdl, lr=lr, hidden_size=hidden_size, dropout=dropout)
        final_stats_sadness.extend(training_stats)
  pd.DataFrame(final_stats_sadness).to_csv('./data/models/bilstm/results/sadness.csv')