Exemple #1
0
import os
import sys
sys.path.append(os.path.abspath(os.path.dirname(__file__) + '/' + '..'))
from models import gru_simple
from helpers import checkpoint

# Get the review summary file
review_summary_file = 'extracted_data/review_summary.csv'

# Initialize Checkpointer to ensure checkpointing
checkpointer = checkpoint.Checkpointer('simple', 'gru', 'Attention')
checkpointer.steps_per_checkpoint(1000)
checkpointer.steps_per_prediction(1000)
# Do using GRU cell - with attention mechanism
out_file = 'result/simple/gru/attention.csv'
checkpointer.set_result_location(out_file)
gru_net = gru_simple.GruSimple(review_summary_file,
                               checkpointer,
                               attention=True)
gru_net.set_parameters(train_batch_size=128,
                       test_batch_size=128,
                       memory_dim=128,
                       learning_rate=0.05)
gru_net.begin_session()
gru_net.form_model_graph()
gru_net.fit()
gru_net.predict()
gru_net.store_test_predictions()
import os
import sys
sys.path.append(os.path.abspath(os.path.dirname(__file__) + '/' + '..'))
from models import lstm_simple
from helpers import checkpoint
# Get the review summary file
review_summary_file = 'extracted_data/review_summary.csv'

# Initialize Checkpointer to ensure checkpointing
checkpointer = checkpoint.Checkpointer('simple', 'lstm', 'Attention')
checkpointer.steps_per_checkpoint(1000)
checkpointer.steps_per_prediction(1000)
# Do using LSTM cell - with attention mechanism
out_file = 'result/simple/lstm/attention.csv'
checkpointer.set_result_location(out_file)
lstm_net = lstm_simple.LstmSimple(review_summary_file,
                                  checkpointer,
                                  attention=True)
lstm_net.set_parameters(train_batch_size=128,
                        test_batch_size=128,
                        memory_dim=128,
                        learning_rate=0.05)
lstm_net.begin_session()
lstm_net.form_model_graph()
lstm_net.fit()
lstm_net.predict()
lstm_net.store_test_predictions()
Exemple #3
0
import os
import sys
sys.path.append(os.path.abspath(os.path.dirname(__file__) + '/' + '..'))
from models import gru_stacked_bidirectional
from helpers import checkpoint

# Get the review summary file
review_summary_file = 'extracted_data/review_summary.csv'

# Initialize Checkpointer to ensure checkpointing
checkpointer = checkpoint.Checkpointer('stackedBidirectional', 'gru',
                                       'Attention')
checkpointer.steps_per_checkpoint(1000)
checkpointer.steps_per_prediction(1000)
# Do using GRU cell - without attention mechanism
out_file = 'result/stacked_bidirectional/gru/attention.csv'
checkpointer.set_result_location(out_file)
gru_net = gru_stacked_bidirectional.GruStackedBidirectional(
    review_summary_file, checkpointer, attention=True, num_layers=2)
gru_net.set_parameters(train_batch_size=128,
                       test_batch_size=128,
                       memory_dim=128,
                       learning_rate=0.05)
gru_net.begin_session()
gru_net.form_model_graph()
gru_net.fit()
gru_net.predict()
gru_net.store_test_predictions()
Exemple #4
0
import os
import sys

sys.path.append(os.path.abspath(os.path.dirname(__file__) + '/' + '..'))
from models import lstm_bidirectional
from helpers import checkpoint

# Get the review summary file
review_summary_file = 'extracted_data/review_summary.csv'

# Initialize Checkpointer to ensure checkpointing
checkpointer = checkpoint.Checkpointer('bidirectional', 'lstm', 'Attention')
checkpointer.steps_per_checkpoint(1000)
checkpointer.steps_per_prediction(1000)
# Do using GRU cell - without attention mechanism
out_file = 'result/bidirectional/lstm/attention.csv'
checkpointer.set_result_location(out_file)
lstm_net = lstm_bidirectional.LstmBidirectional(review_summary_file,
                                                checkpointer,
                                                attention=True)
lstm_net.set_parameters(train_batch_size=128,
                        test_batch_size=128,
                        memory_dim=128,
                        learning_rate=0.05)
lstm_net.begin_session()
lstm_net.form_model_graph()
lstm_net.fit()
lstm_net.predict()
lstm_net.store_test_predictions()
Exemple #5
0
from models import lstm_stacked_simple
from helpers import checkpoint
# Get the review summary file
review_summary_file = 'extracted_data/review_summary.csv'

# Initialize Checkpointer to ensure checkpointing
checkpointer = checkpoint.Checkpointer('stackedSimple', 'lstm', 'Attention')
checkpointer.steps_per_checkpoint(500)
checkpointer.steps_per_prediction(2000)
# Do using GRU cell - without attention mechanism
out_file = 'result/stacked_simple/lstm/attention.csv'
checkpointer.set_result_location(out_file)
lstm_net = lstm_stacked_simple.NeuralNet(review_summary_file,
                                         checkpointer,
                                         attention=True)
lstm_net.set_parameters(train_batch_size=5,
                        test_batch_size=25,
                        memory_dim=50,
                        learning_rate=0.05)
lstm_net.form_model_graph(num_layers=2)
lstm_net.fit()
lstm_net.predict()
lstm_net.store_test_predictions()
lstm_net.close_session()
import os
import sys
sys.path.append(os.path.abspath(os.path.dirname(__file__) + '/' + '..'))
from models import gru_bidirectional
from helpers import checkpoint

# Get the review summary file
review_summary_file = 'extracted_data/review_summary.csv'

# Initialize Checkpointer to ensure checkpointing
checkpointer = checkpoint.Checkpointer('bidirectional', 'gru', 'noAttention')
checkpointer.steps_per_checkpoint(1000)
checkpointer.steps_per_prediction(1000)
# Do using GRU cell - without attention mechanism
out_file = 'result/bidirectional/gru/no_attention.csv'
checkpointer.set_result_location(out_file)
gru_net = gru_bidirectional.GruBidirectional(review_summary_file, checkpointer)
gru_net.set_parameters(train_batch_size=128, test_batch_size=128, memory_dim=128, learning_rate=0.05)
gru_net.begin_session()
gru_net.form_model_graph()
gru_net.fit()
gru_net.predict()
gru_net.store_test_predictions()
import os
import sys
sys.path.append(os.path.abspath(os.path.dirname(__file__) + '/' + '..'))
from models import gru_stacked_simple
from helpers import checkpoint

# Get the review summary file
review_summary_file = 'extracted_data/review_summary.csv'

# Initialize Checkpointer to ensure checkpointing
checkpointer = checkpoint.Checkpointer('stackedSimple', 'gru', 'noAttention')
checkpointer.steps_per_checkpoint(1000)
checkpointer.steps_per_prediction(1000)
# Do using GRU cell - without attention mechanism
out_file = 'result/stacked_simple/gru/no_attention.csv'
checkpointer.set_result_location(out_file)
gru_net = gru_stacked_simple.GruStackedSimple(review_summary_file,
                                              checkpointer,
                                              num_layers=2)
gru_net.set_parameters(train_batch_size=128,
                       test_batch_size=128,
                       memory_dim=128,
                       learning_rate=0.05)
gru_net.begin_session()
gru_net.form_model_graph()
gru_net.fit()
gru_net.predict()
gru_net.store_test_predictions()
Exemple #8
0
import os
import sys
sys.path.append(os.path.abspath(os.path.dirname(__file__) + '/' + '..'))
from models import lstm_stacked_bidirectional
from helpers import checkpoint
# Get the review summary file
review_summary_file = 'extracted_data/review_summary.csv'

# Initialize Checkpointer to ensure checkpointing
checkpointer = checkpoint.Checkpointer('stackedBidirectional', 'lstm',
                                       'noAttention')
checkpointer.steps_per_checkpoint(1000)
checkpointer.steps_per_prediction(1000)
# Do using GRU cell - without attention mechanism
out_file = 'result/stacked_bidirectional/lstm/no_attention.csv'
checkpointer.set_result_location(out_file)
lstm_net = lstm_stacked_bidirectional.LstmStackedBidirectional(
    review_summary_file, checkpointer, num_layers=2)
lstm_net.set_parameters(train_batch_size=128,
                        test_batch_size=128,
                        memory_dim=128,
                        learning_rate=0.05)
lstm_net.begin_session()
lstm_net.form_model_graph()
lstm_net.fit()
lstm_net.predict()
lstm_net.store_test_predictions()