Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests, json
- import datetime as dt
- import errno
- import uuid
- import subprocess
- def uID():
- # generate randomrandomrandomrandomrandomrandomrandomrandom numbers for unique user
- randomid = str(uuid.uuid1()).split('-')[4]
- file = open("unique_id.txt", "w")
- file.write(randomid)
- file.write('\n')
- file.close()
- print("Your model's unique ID is --- ", randomod)
- print('Use the ID to verify the model via NightCrawler app.')
- def teller(iteration='default', itercount='default', maxiter='default', maxepoch='default', epoch='default', trainloss='default', testloss='default',acc='default'):
- '''
- $iteration argument is for counting iterations. type = int.
- $itercount argument is basically a divider, for every how many iterations do you need to update information in the app. type = int.
- $maxiter is a maximum of iterations, after which the model finishes training. Make sure to send +1, as long as
- python takes the 'y' from range(x , y) and finishes the loop when technically y = (y - 1). type = int.
- $maxepoch is amount of epochs you're shooting for
- $epoch counts epochs. type = int.
- $trainloss takes train loss as an information. type = float.
- $testloss takes test loss as an information. type = float.
- $acc takes accuracy as an information. type=float
- '''
- try:
- f = open("unique_id.txt", "r")
- random = f.read()
- except FileNotFoundError:
- subprocess.run('rm unique_id.txt', shell=True)
- print("Unique ID file not found.")
- if iteration % itercount == 0:
- r = requests.post("https://nightcrawlerr.herokuapp.com/sendModelData", data= {'Iteration':iteration, 'Maxiter':maxiter, 'Epoch':epoch, 'MaxEpoch':maxepoch, 'Train Loss':trainloss, 'Test Loss':testloss, 'Accuracy':acc, 'ID':random})
- else:
- print("You're not passing Iteration, Distribution and Maxiter variables correctly. Requests won't be sent.")
- if __name__ == '__main__':
- import requests, json
- import datetime as dt
- from time import sleep
- import random as r
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement