import include_sys_path import numpy as np import unittest from keras.layers import Input from keras.losses import categorical_crossentropy from keras.models import Model from qa.keras_custom_layers import Similarity include_sys_path.void() class TestKerasCustomLayers(unittest.TestCase): def setUp(self): pass def tearDown(self): pass def _do_brute_force(self, x, y, WS): self.assertEqual(len(x.shape), 3) self.assertEqual(len(y.shape), 3) self.assertEqual(x.shape[0], y.shape[0]) self.assertEqual(x.shape[2], y.shape[2]) self.assertEqual(len(WS.shape), 1) self.assertEqual(WS.shape[0], 3 * x.shape[2]) nr_batches = x.shape[0] nr_lines = x.shape[1]
import include_sys_path # This must be the first imported module. from answer.models import Cerebro from answer.settings import TRAIN_PATH, VAL_PATH, TEST_PATH from answer.utils import read_dataset include_sys_path.void() # To remove unused module warning. def predict_and_save_to_file(): from answer.settings import KAGGLE_CONTEST_PATH data = read_dataset(KAGGLE_CONTEST_PATH) model = Cerebro() rez = model.predict(data) with open("submission.csv", "w") as g: g.write("id,correctAnswer\n") for q_id, ans in rez: g.write(q_id) g.write(",") g.write(chr(65 + int(ans))) g.write("\n") g.flush() def main(): train_data = [] for path in TRAIN_PATH: train_data += read_dataset(path)