ya_train[tbr_train] = np.take(ya_train, good_candidates_train) xa_train[tbr_train, ] = np.take(xa_train, good_candidates_train, 0) # Accelerometer and silhouette training vectors are the same, they're both # calories. They originally contain different NaN, but once these are replaced # only one training vector is needed y_train = ya_train # Remove Nan data from test nan_test = np.logical_or(np.isnan(ya_test), np.isnan(yv_test)) xv_test = np.delete(xv_test, np.where(nan_test), 0) xa_test = np.delete(xa_test, np.where(nan_test), 0) y_test = np.delete(yv_test, np.where(nan_test)) # Network model = NetworkCombined(img_rows, img_cols, Nv_chan, acc_buffersiz, Na_chan) model.summary() opt = keras.optimizers.RMSprop() #(lr=3e-3) model.compile(optimizer=opt, loss='mean_squared_error', metrics=['accuracy']) best_model_name = '%s_best.h5' % network_name # Callbacks filepath = os.path.join(save_dir, best_model_name) save_history = SaveHistory() save_history.SetFilename(network_name, save_dir) if Set['bluecrystal']: callbacks = [save_history]
nan_test = np.logical_or(np.isnan(ya_test), np.isnan(yv_test)) xv_test = np.delete(xv_test, np.where(nan_test), 0) xa_test = np.delete(xa_test, np.where(nan_test), 0) y_test = np.delete(yv_test, np.where(nan_test)) lab_test = np.delete(lab_test, np.where(nan_test)) # Initialize the network structure if si == 1: # Initialise error per label Nlabels = 11 R_per_lab = np.zeros(Nlabels) err_per_lab = np.zeros(Nlabels) N_per_lab = np.zeros(Nlabels) # Network model = NetworkCombined(img_rows, img_cols, Nv_chan, acc_buffersiz, Na_chan) # Read the model weights file_name = os.path.join(model_path, model_name % (buffer_tested[bi], si)) if os.path.isfile(file_name): print('Loading model for leave %s out' % file_name) model.load_weights(file_name) else: print( 'FILE NOT FOUND! PREDICTING WITH RANDOM WEIGHTS! **********************************************' ) # Predict the results print('Predicting the result...')