Numpy-Neuron / example /neural_network.py
Jensen-holm's picture
instead of returning the image bytes to the api user, we are moving towards hosting them on the backend but we need to be careful moving forwards and make sure that we delete the images after use
28d5b3d
raw
history blame
663 Bytes
import matplotlib.pyplot as plt
import seaborn as sns
import requests
import json
ENDPOINT: str = "http://127.0.0.1:5000/neural-network"
request_params = {
"arguments": {
"epochs": 100,
"activation_func": "tanh",
"hidden_size": 8,
"learning_rate": 0.01
}
}
headers = {
"Content-Type": "application/json",
}
r = requests.post(
ENDPOINT,
headers=headers,
data=json.dumps(request_params),
)
model = r.json()
def plot():
sns.set()
plt.plot(model["loss_history"])
plt.xlabel("Epoch")
plt.ylabel("Loss")
plt.title("Loss History")
plt.show()
if __name__ == "__main__":
plot()