(sess, ops, train_writer)
ops: dict mapping from string to tf ops
ops: dict mapping from string to tf ops
ops : dict mapping from string to tf ops
def train_one_epoch(sess, ops, train_writer):
    """ ops: dict mapping from string to tf ops """
    start_time = time.time()

    is_training_sampler = True
    is_training_classifier = False

    # Shuffle train files
    train_file_idxs = np.arange(0, len(TRAIN_FILES))
    np.random.shuffle(train_file_idxs)

    for fn in range(len(TRAIN_FILES)):
        log_string("----" + str(fn) + "-----")
        current_data, current_label = provider.loadDataFile(
            TRAIN_FILES[train_file_idxs[fn]]
        )

        current_data = current_data[:, 0:NUM_IN_POINTS, :]
        current_data, current_label, _ = provider.shuffle_data(
            current_data, np.squeeze(current_label)
        )
        current_label = np.squeeze(current_label)
        file_size = current_data.shape[0]
        num_batches = file_size // BATCH_SIZE

        total_correct = 0
        total_seen = 0
        loss_sum = 0

        for batch_idx in range(num_batches):
            start_idx = batch_idx * BATCH_SIZE
            end_idx = (batch_idx + 1) * BATCH_SIZE

            feed_dict = {
                ops["pointclouds_pl"]: current_data[start_idx:end_idx, :, :],
                ops["labels_pl"]: current_label[start_idx:end_idx],
                ops["is_training_sampler_pl"]: is_training_sampler,
                ops["is_training_classifier_pl"]: is_training_classifier,
            }

            if is_training_classifier:
                summary, step, _, loss_val, pred_val = sess.run(
                    [
                        ops["merged"],
                        ops["step"],
                        ops["train_op"],
                        ops["loss_classifier"],
                        ops["pred"],
                    ],
                    feed_dict=feed_dict,
                )
            else:
                summary, step, _, loss_val, pred_val = sess.run(
                    [
                        ops["merged"],
                        ops["step"],
                        ops["train_op"],
                        ops["loss"],
                        ops["pred"],
                    ],
                    feed_dict=feed_dict,
                )

            train_writer.add_summary(summary, step)
            pred_val = np.argmax(pred_val, 1)
            correct = np.sum(pred_val == current_label[start_idx:end_idx])
            total_correct += correct
            total_seen += BATCH_SIZE
            loss_sum += loss_val

        log_string("mean loss: %f" % (loss_sum / float(num_batches)))
        log_string("accuracy: %f" % (total_correct / float(total_seen)))

    duration = time.time() - start_time
    log_string("epoch duration (minutes): %.4f" % (duration / 60.0))
def train_one_epoch ( sess , ops , train_writer ) : start_time = time . time ( ) is_training_sampler = True is_training_classifier = False # Shuffle train files train_file_idxs = np . arange ( 0 , len ( TRAIN_FILES ) ) np . random . shuffle ( train_file_idxs ) for fn in range ( len ( TRAIN_FILES ) ) : log_string ( "----" + str ( fn ) + "-----" ) current_data , current_label = provider . loadDataFile ( TRAIN_FILES [ train_file_idxs [ fn ] ] ) current_data = current_data [ : , 0 : NUM_IN_POINTS , : ] current_data , current_label , _ = provider . shuffle_data ( current_data , np . squeeze ( current_label ) ) current_label = np . squeeze ( current_label ) file_size = current_data . shape [ 0 ] num_batches = file_size // BATCH_SIZE total_correct = 0 total_seen = 0 loss_sum = 0 for batch_idx in range ( num_batches ) : start_idx = batch_idx * BATCH_SIZE end_idx = ( batch_idx + 1 ) * BATCH_SIZE feed_dict = { ops [ "pointclouds_pl" ] : current_data [ start_idx : end_idx , : , : ] , ops [ "labels_pl" ] : current_label [ start_idx : end_idx ] , ops [ "is_training_sampler_pl" ] : is_training_sampler , ops [ "is_training_classifier_pl" ] : is_training_classifier , } if is_training_classifier : summary , step , _ , loss_val , pred_val = sess . run ( [ ops [ "merged" ] , ops [ "step" ] , ops [ "train_op" ] , ops [ "loss_classifier" ] , ops [ "pred" ] , ] , feed_dict = feed_dict , ) else : summary , step , _ , loss_val , pred_val = sess . run ( [ ops [ "merged" ] , ops [ "step" ] , ops [ "train_op" ] , ops [ "loss" ] , ops [ "pred" ] , ] , feed_dict = feed_dict , ) train_writer . add_summary ( summary , step ) pred_val = np . argmax ( pred_val , 1 ) correct = np . sum ( pred_val == current_label [ start_idx : end_idx ] ) total_correct += correct total_seen += BATCH_SIZE loss_sum += loss_val log_string ( "mean loss: %f" % ( loss_sum / float ( num_batches ) ) ) log_string ( "accuracy: %f" % ( total_correct / float ( total_seen ) ) ) duration = time . time ( ) - start_time log_string ( "epoch duration (minutes): %.4f" % ( duration / 60.0 ) )