예제 #1
0
from hare import Hare, Conversation
from hare.brain import BiGruBrain

brain: BiGruBrain = BiGruBrain()
brain.embedding_location = '/vol/bigdata/word_embeddings/glove/glove.6B.50d.txt'
brain.verbose = True

hare = Hare()
hare.brain = brain

convo = Conversation()
convo.add_utterance(speaker='a', content='hate you')
convo.add_utterance(speaker='b', content='i love you')
convo.label_speaker('a', 1)

hare.add_conversation(convo)

hare.train()
hare.save('/vol/tensusers2/wstoop/HaRe/hare/pretrained/simple')

hare.update_status_history_for_conversation()
hare.visualize_history_for_conversation()
예제 #2
0
        try:
            current_conversation.label_speaker(line.split()[1], 1)
        except IndexError:
            continue

        conversations.append(current_conversation)
        current_conversation = Conversation()

        if len(conversations) % 100 == 0:
            print(len(conversations))

        if len(conversations) == NR_OF_CONVERSATIONS:
            break

        continue

    speaker, content = line.split('\t')
    current_conversation.add_utterance(speaker, content)

#Add to a hare object
moba_hare = Hare()
for conversation in conversations:
    moba_hare.add_conversation(conversation)

moba_hare.brain = BiGruBrain()
moba_hare.brain.downsampling = True
moba_hare.brain._max_sequence_length = 500

moba_hare.train()
moba_hare.save('moba')
예제 #3
0
from hare import Hare, Conversation
from hare.tensorflowbrain import LSTMBrain, BiGruBrain
from hare.conversation import import_conversations

from hare.embedding import load_embedding_dictionary

#Load the conversations
DATA_ROOT = '../datasets/LoL/'
CONVERSATIONS_FILE = DATA_ROOT+'train_conversations_anon.txt'
print('Importing conversations')
conversations = import_conversations(CONVERSATIONS_FILE)

#Add to a hare object
moba_hare = Hare()
for conversation in conversations:
    moba_hare.add_conversation(conversation)

brain = BiGruBrain()
brain.embedding_location = DATA_ROOT+'train_toxic_embeddings'
brain.verbose = True
brain.downsampling = True
brain.learning_epochs = 10
brain._max_sequence_length = 500
brain.include_casing_information = True

moba_hare.brain = brain
moba_hare.train()
moba_hare.save('m05')
예제 #4
0
        current_conversation = Conversation()

        if len(conversations) % 100 == 0:
            print(len(conversations))

        if len(conversations) == NR_OF_CONVERSATIONS:
            break

        continue

    speaker, content = line.split('\t')
    current_conversation.add_utterance(speaker, content)

#Add to a hare object
for downsample_ratio in DOWNSAMPLE_RATIOS:
    for training_size in TRAINING_SIZES:

        print('===', 'training', downsample_ratio, training_size, '===')

        exp_hare = Hare()
        for conversation in conversations[:training_size]:
            exp_hare.add_conversation(conversation)

        exp_hare.brain = BiGruBrain()
        exp_hare.brain.downsampling = True
        exp_hare.brain.downsampling_ratio = downsample_ratio
        exp_hare.brain._max_sequence_length = 500

        exp_hare.train()
        exp_hare.save('moba_' + str(downsample_ratio) + '_' +
                      str(training_size))
예제 #5
0
from hare import Hare, Conversation
from hare.tensorflowbrain import LSTMBrain, BiGruBrain
from hare.conversation import import_conversations

from hare.embedding import load_embedding_dictionary

#Load the conversations
DATA_ROOT = '../datasets/LoL/'
CONVERSATIONS_FILE = DATA_ROOT + 'train_conversations_anon.txt'
print('Importing conversations')
conversations = import_conversations(CONVERSATIONS_FILE)

#Add to a hare object
moba_hare = Hare()
for conversation in conversations:
    moba_hare.add_conversation(conversation)

brain = BiGruBrain()
brain.embedding_location = DATA_ROOT + 'train_toxic_embeddings'
brain.verbose = True
brain.downsampling = True
brain.learning_epochs = 10
brain._max_sequence_length = 500
brain.include_casing_information = False
brain.bidirectional = False

moba_hare.brain = brain
moba_hare.train()
moba_hare.save('m06')
예제 #6
0
from hare import Hare, Conversation
from hare.tensorflowbrain import LSTMBrain, BiGruBrain
from hare.conversation import import_conversations

from hare.embedding import load_embedding_dictionary

#Load the conversations
CONVERSATIONS_FILE = 'datasets/LoL/train_conversations_anon.txt'
print('Importing conversations')
conversations = import_conversations(CONVERSATIONS_FILE)

#Add to a hare object
moba_hare = Hare()
for conversation in conversations:
    moba_hare.add_conversation(conversation)

moba_hare.brain = BiGruBrain()
moba_hare.brain.embedding_location = 'datasets/LoL/train_toxic_embeddings'
moba_hare.brain.verbose = True
moba_hare.brain.downsampling = True
moba_hare.brain.learning_epochs = 10
moba_hare.brain._max_sequence_length = 500

moba_hare.train()
moba_hare.save('moba_bigru_embedding')