def load(cls, path, nlp, max_length=100): with (path / 'config.json').open() as file_: model = model_from_json(file_.read()) with (path / 'model').open('rb') as file_: lstm_weights = pickle.load(file_) embeddings = get_embeddings(nlp.vocab) model.set_weights([embeddings] + lstm_weights) return cls(model, max_length=max_length)
def load(cls, path, nlp, max_length=100): with (path / "config.json").open() as file_: model = model_from_json(file_.read()) with (path / "model").open("rb") as file_: lstm_weights = pickle.load(file_) embeddings = get_embeddings(nlp.vocab) model.set_weights([embeddings] + lstm_weights) return cls(model, max_length=max_length)
def load(cls, path, nlp, max_length=100): print('> max_length: {}'.format(max_length)) print('> path: {}'.format(path)) with (path / "config.json").open() as file_: model = model_from_json(file_.read()) with (path / "model").open("rb") as file_: lstm_weights = pickle.load(file_) embeddings = get_embeddings(nlp.vocab) model.set_weights([embeddings] + lstm_weights) return cls(model, max_length=max_length)
def load(cls, path, char_index, max_length, frozen): xprint('SentimentAnalyser.load: path=%s max_length=%d' % (path, max_length)) with open(os.path.join(path, 'config.json'), 'rt') as f: model = model_from_json(f.read()) with open(os.path.join(path, 'model'), 'rb') as f: lstm_weights = pickle.load(f) if frozen: embeddings, char_index, index_char = get_char_embeddings() lstm_weights = [embeddings] + lstm_weights model.set_weights(lstm_weights) return cls(char_index, model, max_length=max_length)
def load_model(path, nlp): with (path / 'model_config.json').open() as file_: _json = file_.read() config_dict = json.loads(_json) image_embedding_function = config_dict.get( IMAGE_EMBEDDING_FUNCTION_KEY, None) if IMAGE_EMBEDDING_FUNCTION_KEY in config_dict: del config_dict[IMAGE_EMBEDDING_FUNCTION_KEY] model = model_from_config(config_dict) with (path / 'model_weights').open('rb') as file_: lstm_weights = pickle.load(file_) embeddings = get_embeddings(nlp.vocab) model.set_weights([embeddings] + lstm_weights) return model, config_dict, image_embedding_function
def reader(input_path): f = open(input_path, 'rb') data = pickle.load(f) print(data) print(len(data))