Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

evaluate.py 919 B

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
  1. # -*- coding: utf-8 -*-
  2. """
  3. Created on Wed Jan 5 19:30:00 2022
  4. @author: AMIT CHAKRABORTY
  5. """
  6. import sklearn.metrics as metrics
  7. import pickle
  8. import json
  9. import numpy as np
  10. from keras.models import load_model
  11. from keras.models import model_from_json
  12. import json
  13. def evaluate_model():
  14. json_file = open('model_in_json.json', 'r')
  15. loaded_model_json = json_file.read()
  16. json_file.close()
  17. loaded_model = model_from_json(loaded_model_json)
  18. loaded_model.load_weights('saved-models/weights.h5')
  19. test_data = np.load('data/test_data.npy')
  20. test_label = np.load('data/test_label.npy')
  21. test_score = loaded_model.evaluate(test_data, test_label)
  22. print('loss',test_score[0])
  23. print('accuracy',test_score[1])
  24. with open("scores.json", "w") as fd:
  25. json.dump({"loss": test_score[0], "accuracy": test_score[1]}, fd, indent=4)
  26. if __name__ == '__main__':
  27. evaluate_model()
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...