def __init__(self): ''' You can add more arguments for examples actions and model paths. You need to load your model here. actions: provides indices for actions. it has the same order as the data/vocabs.actions file. ''' self.index_of_words = getIndex(filename='data/vocabs.word') self.index_of_pos = getIndex(filename='data/vocabs.pos') self.index_of_labels = getIndex(filename='data/vocabs.labels') self.index_of_actions = getIndex(filename='data/vocabs.actions') index_of_actions_items = self.index_of_actions.items() sorted_index_of_actions = sorted(index_of_actions_items, key=lambda x: x[1]) sorted_actions = [x[0] for x in sorted_index_of_actions] self.actions = sorted_actions self.model = load_model('models/model3')
# -*- coding: utf-8 -*- """ Created on Wed Apr 24 01:57:28 2019 @author: yiwenzhang """ import tensorflow as tf import numpy as np from utils_1 import Indexing, getIndex, loadnew import sys from keras.models import Model from keras.layers import Dense, Input, Embedding, Reshape, Concatenate, Lambda import keras index_of_words = getIndex(filename='./data/vocabs.word') index_of_labels = getIndex(filename='./data/vocabs.labels') index_of_pos = getIndex(filename='./data/vocabs.pos') index_of_actions = getIndex(filename='./data/vocabs.actions') Indexing( file1='./data/train.data', file2='./data/train_with_indices.data', indices=[index_of_words, index_of_pos, index_of_labels, index_of_actions]) train_data, train_labels = loadnew(filename='./data/train_with_indices.data') def output_shape_words(input_shape): assert (len(list(input_shape)) == 2) assert (input_shape[1] == 52) return (input_shape[0], 20)