I have already built an lstm model and now I want to post some values and get back the results.
so when I go to the postman and in http://127.0.0.1:8000/api i post the following raw data
ValueError: Error when checking input: expected lstm_1_input to have 3 dimensions, but got array with shape (6, 1)
any ideas: the code is below
so when I go to the postman and in http://127.0.0.1:8000/api i post the following raw data
{"accx":0.660583, "accy":0.454468, "accz":-0.585022, "gyrx":32.366615, "gyry":27.206556, "gyrz":-23.471800}
i get backValueError: Error when checking input: expected lstm_1_input to have 3 dimensions, but got array with shape (6, 1)
any ideas: the code is below
from flask import Flask, request, jsonify#--jsonify will return the data from keras.models import load_model import numpy as np import pandas as pd #creates the web service running on port 127.0.0.1:12345 and answer post requests on adress/api app = Flask(__name__) model=load_model('flask_model.h5') @app.route("/") def hello(): return "machine learning model APIs!" @app.route('/api', methods=["POST"]) def predict(): # get the json send from the post as data data=request.get_json(force=True) print (data) #i expected jason to have the following values predict_request=[data["accx"], data["accy"], data["accz"],data["gyrx"], data["gyry"], data["gyrz"]] print (predict_request) predict_request= np.array(predict_request) print (predict_request) pred= model.predict(predict_request) print (pred) output=[pred[0]] print (output) #take a list of dictionaries and convert them to jason return jsonify(results=output) if __name__ == '__main__': app.run(port=8000, debug=True)