data[1], config, activation='relu') # lips dyn_lips_preds = ref_feature_map_neuron(lips_preds, data[1], config, activation='relu') print("[TRAIN] finished computing dynamic predictions") print() # compute positions eyebrow dyn_eyebrow_pos = calculate_position(dyn_eyebrow_preds, mode="weighted average", return_mode="xy float flat") nb_model_eyebrow.n_features = np.shape(dyn_eyebrow_pos)[ -1] # todo add this to init # train manually ref vector nb_model_eyebrow.r = np.zeros(nb_model_eyebrow.n_features) nb_model_eyebrow._fit_reference([dyn_eyebrow_pos, data[1]], config['batch_size']) # train manually tuning vector nb_model_eyebrow.t = np.zeros( (nb_model_eyebrow.n_category, nb_model_eyebrow.n_features)) nb_model_eyebrow.t_mean = np.zeros( (nb_model_eyebrow.n_category, nb_model_eyebrow.n_features)) nb_model_eyebrow._fit_tuning([dyn_eyebrow_pos, data[1]], config['batch_size']) # get it resp for eyebrows it_train_eyebrow = nb_model_eyebrow._get_it_resp(dyn_eyebrow_pos) print("[TRAIN] finished computing eyebrow positions") print()
print("[TRAIN] finished computing dynamic predictions") # compute positions eyebrow dyn_pos = calculate_position(dyn_preds, mode="weighted average", return_mode="xy float flat") print("[TRAIN] shape dyn_pos", np.shape(dyn_pos)) # add weights pos_weights = np.ones(np.shape(dyn_pos)[-1]) pos_weights[:8] = 1 / (2 * 2 * len(best_eyebrow_IoU_ft) ) # num_concept * x/y * num_ft/concept pos_weights[8:] = 1 / (2 * 2 * len(best_lips_IoU_ft)) dyn_pos = np.multiply(dyn_pos, pos_weights) nb_model.n_features = np.shape(dyn_pos)[-1] # todo add this to init # train manually ref vector nb_model.r = np.zeros(nb_model.n_features) nb_model._fit_reference([dyn_pos, data[1]], config['batch_size']) # train manually tuning vector nb_model.t = np.zeros((nb_model.n_category, nb_model.n_features)) nb_model.t_mean = np.zeros((nb_model.n_category, nb_model.n_features)) nb_model._fit_tuning([dyn_pos, data[1]], config['batch_size']) # get it resp for eyebrows it_train = nb_model._get_it_resp(dyn_pos) print("[TRAIN] finished computing positions") print() # ------------------------------------------------------------------------------------------------------------------- # test monkey
preds[2, 3, 2, 1] = 1 print("[TRAIN] preds", np.shape(preds)) print("preds[1]") print(preds[1, ..., 0]) print("preds[1]") print(preds[1, ..., 1]) # compute positions pos = calculate_position(preds, mode="weighted average", return_mode="xy float flat") print("[TRAIN] shape pos", np.shape(pos)) print(pos) print() nb_model.n_features = np.shape(pos)[-1] # train manually ref vector nb_model.r = np.zeros(nb_model.n_features) nb_model._fit_reference([pos, labels], config['batch_size']) print("model reference") print(nb_model.r) print() # train manually tuning vector nb_model.t = np.zeros((nb_model.n_category, nb_model.n_features)) nb_model.t_mean = np.zeros((nb_model.n_category, nb_model.n_features)) nb_model._fit_tuning([pos, labels], config['batch_size']) nb_model.t[3:] = 0 print("model tuning") print(nb_model.t) print() # get it resp for eyebrows