def RunNet(name): """Runs a given net. Inputs: name: the name of the net, or a reference to the net. Returns: True or an exception. """ return C.run_net(StringifyNetName(name))
def RunNet(name, num_iter=1): """Runs a given net. Inputs: name: the name of the net, or a reference to the net. num_iter: number of iterations to run Returns: True or an exception. """ return C.run_net(StringifyNetName(name), num_iter)
def RunNet(name, num_iter=1, allow_fail=False): """Runs a given net. Inputs: name: the name of the net, or a reference to the net. num_iter: number of iterations to run allow_fail: if True, does not assert on net exec failure but returns False Returns: True or an exception. """ return C.run_net(StringifyNetName(name), num_iter, allow_fail)
C.create_net(net_def.SerializeToString()) C.feed_blob('data', img, device_opts.SerializeToString()) ### Debug code """ for b in workspace.Blobs(): x = workspace.FetchBlob(b) if type(x) != str: print(str(b) + ': ' + str(x.shape)) """ ### End of debug code print('Running net ' + workspace.GetNetName(net_def) + '...') C.run_net(workspace.GetNetName(net_def), 1, False) # Turn it into something we can play with and examine which is in a multi-dimensional array results = workspace.FetchBlob('prob') #print("results shape: ", results.shape) # Quick way to get the top-1 prediction result # Squeeze out the unnecessary axis. This returns a 1-D array of length 1000 preds = np.squeeze(results) # Get the prediction and the confidence by finding the maximum value and index of maximum value in preds array curr_pred, curr_conf = max(enumerate(preds), key=operator.itemgetter(1)) print("Prediction: ", curr_pred) print("Confidence: ", curr_conf) # the rest of this is digging through the results results = np.delete(results, 1)