Training the network

Now that my sentiment analysis network is built, it's time to train:

data = load_data(20000)
data = pad_sequences(data)
model = build_network(vocab_size=data["vocab_size"],
embedding_dim=100,
sequence_length=data["sequence_length"])

callbacks = create_callbacks("sentiment")

model.fit(x=data["X_train"], y=data["y_train"],
batch_size=32,
epochs=10,
validation_data=(data["X_test"], data["y_test"]),
callbacks=callbacks)

Keeping all of my training parameters and data in a single dictionary like this is just really a question of style and less about function. You may prefer to handle everything separately. I like using a dictionary for everything because it keeps me from passing big lists of parameters back and forth.

Since we're using a stateless LSTM, we're resetting cell memory in every batch. My belief is that we can probably reset cell states between documents without penalty, so then the batch size really becomes about performance. I'm using 32 observation batches here, but 128 observation batches yield similar results with a slight performance boost as long as your GPU memory allows it.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.179.35