def doNN(data): global submit_work data_fft = np.fft.fft(data) data_scaled = scaleData(data_fft) data_scaled_reshaped = data_scaled data_scaled_reshaped.shape = (3, 3000) prediction = str(np.sum(score(data_scaled_reshaped)) / 3) print("Prediction: %s, publishing..." % (prediction)) myData = {'healthy': prediction} client.publishEvent("0.16.2", "lorenz", "status", "json", myData) if submit_work: submit_work = False parts_data["ZzEP8"] = json.dumps(myData) submitAll(email, secret, key, parts_data) print("Submitting to grader: %s" % (json.dumps(myData))) print("Done")
# In[34]: part = "O5cR9" secret = "HNKTKFFyRCl3BrmY" parts_data = {} parts_data["0dXlH"] = json.dumps({ "number_of_neurons_layer1": 0, "number_of_neurons_layer2": 0, "number_of_neurons_layer3": 0, "number_of_epochs": 0 }) parts_data["O5cR9"] = json.dumps({"dim": dim, "samples": samples}) parts_data["ZzEP8"] = None submitAll(email, secret, key, parts_data) # To observe how training works we just print the loss during training # In[89]: class LossHistory(Callback): def on_train_begin(self, logs={}): self.losses = [] def on_batch_end(self, batch, logs={}): sys.stdout.write(str(logs.get('loss')) + str(', ')) sys.stdout.flush() self.losses.append(logs.get('loss'))
dim = 3000 #### your code here ### samples = 3 #### your code here ### # ### Submission # # Now it’s time to submit your first solution. Please make sure that the secret variable contains a valid submission token. You can obtain it from the courser web page of the course using the grader section of this assignment. # # In[20]: part = "O5cR9" secret = "8s4TiWZVfTYyoRIp" submitAll( email, secret, key, dict((p, json.dumps({}) if p != part else json.dumps({ "dim": dim, "samples": samples })) for p in all_parts)) # To observe how training works we just print the loss during training # In[21]: class LossHistory(Callback): def on_train_begin(self, logs={}): self.losses = [] def on_batch_end(self, batch, logs={}): sys.stdout.write(str(logs.get('loss')) + str(', ')) sys.stdout.flush()
plt.show() # Congratulations, you are done! The following code submits your solution to the grader. Again, please update your token from the grader's submission page on Coursera # In[15]: get_ipython().system('rm -f rklib.py') get_ipython().system( 'wget https://raw.githubusercontent.com/IBM/coursera/master/rklib.py') # In[17]: from rklib import submitAll import json key = "S5PNoSHNEeisnA6YLL5C0g" email = "*****@*****.**" token = "cuV16XmPypbDcP7f" # In[18]: parts_data = {} parts_data["iLdHs"] = json.dumps(str(type(getListForHistogramAndBoxPlot()))) parts_data["xucEM"] = json.dumps(len(getListForHistogramAndBoxPlot())) parts_data["IyH7U"] = json.dumps(str(type(getListsForRunChart()))) parts_data["MsMHO"] = json.dumps(len(getListsForRunChart()[0])) submitAll(email, token, key, parts_data) # In[ ]: