Esempio n. 1
0
import numpy as np
import pandas as pd
import pdb
from collections import defaultdict
from mmdata import MOSI
import argparse
from collections import defaultdict
from mmdata.dataset import Dataset
from utils.parser_utils import KerasParserClass
from utils.storage import build_experiment_folder, save_statistics

parser = argparse.ArgumentParser(
    description='Welcome to LSTM experiments script'
)  # generates an argument parser
parser_extractor = KerasParserClass(
    parser=parser)  # creates a parser class to process the parsed input

batch_size, seed, epochs, logs_path, continue_from_epoch, batch_norm, \
experiment_prefix, dropout_rate, n_layers, max_len = parser_extractor.get_argument_variables()

experiment_name = "experiment_{}_batch_size_{}_bn_{}_dr{}_nl_{}_ml_{}".format(
    experiment_prefix, batch_size, batch_norm, dropout_rate, n_layers, max_len)
np.random.seed(seed)
import os
os.environ['PYTHONHASHSEED'] = '0'
import tensorflow as tf
tf.set_random_seed(seed)
# The below is necessary for starting Numpy generated random numbers
# in a well-defined initial state.

# The below is necessary for starting core Python generated random numbers
Esempio n. 2
0
from keras.optimizers import SGD
from keras.layers.merge import concatenate
from keras.models import Sequential
from keras.optimizers import Adam
from keras.layers import Dense, Dropout, Embedding, LSTM, Bidirectional, BatchNormalization
from keras.callbacks import ModelCheckpoint, EarlyStopping, TensorBoard, CSVLogger

import logging
logging.basicConfig(filename="train-intermediate-late-fusion.log",
                    level=logging.INFO)
logging.root.level = logging.INFO

parser = argparse.ArgumentParser(
    description='Welcome to LSTM experiments script'
)  # generates an argument parser
parser_extractor = KerasParserClass(
    parser=parser)  # creates a parser class to process the parsed input

batch_size = 64
seed = 1122017
epochs = 50
dropout_rate = 0.1
logs_path = "classification_logs/"
experiment_prefix = "late_fusion"
continue_from_epoch = -1
batch_norm = False
n_layers = 1

experiment_name = "Late_fusion" + time.strftime("%Y-%m-%d %H:%M")
saved_models_filepath, logs_filepath = build_experiment_folder(
    experiment_name, logs_path)
filepath = "{}/best_validation_{}".format(saved_models_filepath,