def save_test_summary(x_batch, y_batch, x_strings_batch, name_): ''' save info for a batch in order to plot in bokeh later ''' path_ = os.path.join(out_dir, name_) y_net = [] prob_net = [] layer = [] true_labels = [] feed_dict = { x_values: x_batch, y_values: y_batch, dropout_prob: 1.0 } output_ = [graph_predictions, graph_true_predictions, graph_probs, graph_state_] predictions, true_pred, probs, fc_layer = sess.run( output_, feed_dict) prob_net = probs.tolist() layer = fc_layer.tolist() y_net = predictions.tolist() true_labels = true_pred.tolist() process_utils.save_info( x_strings_batch, true_labels, y_net, prob_net, layer, path_)
def save_dev_summary(x_batch, y_batch, x_strings_batch, name_): ''' save info for a batch in order to plot in bokeh later ''' path_ = os.path.join(sent_dir, name_) y_net = [] prob_net = [] layer = [] true_labels = [] feed_dict = { network.x: x_batch, network.y: y_batch, network.dropout_prob: 1.0 } output_ = [ network.predictions, network.true_predictions, network.probs, network.h_pool_flat ] predictions, true_pred, probs, fc_layer = sess.run(output_, feed_dict) prob_net = probs.tolist() layer = fc_layer.tolist() y_net = predictions.tolist() true_labels = true_pred.tolist() process_utils.save_info(x_strings_batch, true_labels, y_net, prob_net, layer, path_)
def save_test_summary(x_batch, y_batch, x_strings_batch, name_): ''' save info for a batch in order to plot in bokeh later ''' path_ = os.path.join(out_dir, name_) y_net = [] prob_net = [] layer = [] true_labels = [] flag_ = True if config['split_dev']: mini_size = config['dev_minibatch'] for i in range(0, len(x_batch), mini_size): if (i + mini_size < len(x_batch)): mini_x_batch = x_batch[i:i + mini_size] mini_y_batch = y_batch[i:i + mini_size] else: mini_x_batch = x_batch[i:] mini_y_batch = y_batch[i:] dropouts = [1.0, 1.0, 1.0] reg_metrics = [1, 0, 0] feed_dict = make_feed_dict( mini_x_batch, mini_y_batch, dropouts, reg_metrics, question) output_ = [graph_predictions, graph_true_predictions, graph_probs, graph_state_, graph_embeddings] predictions, true_pred, probs, fc_layer, embds_ = sess.run( output_, feed_dict) if flag_: # save word_embeddings flag_ = False save_embeddings(embds_) prob_net += probs.tolist() layer += fc_layer.tolist() y_net += predictions.tolist() true_labels += true_pred.tolist() else: print ( "doesn't support having input as a single batch!! Set:" "config['split_dev'] to True ") sys.exit(1) # print ( # len(x_strings_batch), len(true_labels), len(y_net), # len(prob_net), len(layer)) process_utils.save_info( x_strings_batch, true_labels, y_net, prob_net, layer, path_) print ("saved info to: {}".format(path_))
def save_dev_summary(x_batch, y_batch, x_strings_batch, name_): ''' save info for a batch in order to plot in bokeh later ''' path_ = os.path.join(out_dir, name_) y_net = [] prob_net = [] layer = [] true_labels = [] if config['split_dev']: mini_size = config['dev_minibatch'] for i in range(0, len(x_batch), mini_size): if (i + mini_size < len(x_batch)): mini_x_batch = x_batch[i:i + mini_size] mini_y_batch = y_batch[i:i + mini_size] else: mini_x_batch = x_batch[i:] mini_y_batch = y_batch[i:] dropouts = [1.0, 1.0, 1.0] reg_metrics = [1, 0, 0] feed_dict = make_feed_dict(mini_x_batch, mini_y_batch, dropouts, reg_metrics, question) output_ = [ network.predictions, network.true_predictions, network.probs, network.state_ ] predictions, true_pred, probs, fc_layer = sess.run( output_, feed_dict) # print (predictions) # print (probs) # print (fc_layer) # print (fc_layer.shape) # print (true_pred) prob_net += probs.tolist() layer += fc_layer.tolist() y_net += predictions.tolist() true_labels += true_pred.tolist() else: print("doesn't support having input as a single batch!! Set:" "config['split_dev'] to True ") sys.exit(1) # print ( # len(x_strings_batch), len(true_labels), len(y_net), # len(prob_net), len(layer)) process_utils.save_info(x_strings_batch, true_labels, y_net, prob_net, layer, path_)