print("No test data") exit() if 'vision_path' in dir() and 'vision_path' is not None and not os.access( vision_path, os.F_OK): os.makedirs(vision_path) if os.access(evaluation_path, os.F_OK): shutil.rmtree(evaluation_path) os.makedirs(evaluation_path) x = tf.placeholder(tf.float32, [None, REGION_SIZE, REGION_SIZE, REGION_SIZE]) x_image = tf.reshape(x, [-1, REGION_SIZE, REGION_SIZE, REGION_SIZE, 1]) bn_params = np.load(bn_file) outputs, _, _ = tft.volume_bndo_flbias_l5_30( x_image, dropout_rate=0.0, batch_normalization_statistic=False, bn_params=bn_params) prediction_out = outputs['sm_out'] saver = tf.train.Saver() config = tf.ConfigProto() config.gpu_options.allow_growth = True sess = tf.Session(config=config) saver.restore(sess, net_file) start_time = time.time() #patient_evaluations = open(evaluation_path + "/patient_evaluations.log", "w") results = [] CPMs = [] CPMs2 = [] test_patients = all_patients[4:5]
#bn_params = np.load(net_init_path + "/batch_normalization_statistic.npy") aug_proportion = (1 + 2 * int(SCALE_AUGMENTATION)) * ( 1 + 26 * int(TRANSLATION_AUGMENTATION) * (1 + 2 * int(CENTERING))) * (1 + 9 * int(ROTATION_AUGMENTATION) + 3 * int(FLIP_AUGMENTATION)) if ALL_NEGATIVE: np_proportion = negative_train_num / float(positive_train_num) else: np_proportion = aug_proportion num_positive_aug = positive_train_num * aug_proportion positive_confidence = num_positive_aug / float( num_positive_aug + positive_train_num * np_proportion) net_outs, _, bn_params = tft.volume_bndo_flbias_l5_30( volume_reshape, True, positive_confidence, dropout_rate=0.3, batch_normalization_statistic=True, bn_params=None) loss = tf.nn.softmax_cross_entropy_with_logits(logits=net_outs['last_out'], labels=real_label) if type(LOSS_BALANCING) == float: balancing_factor = LOSS_BALANCING else: balancing_factor = positive_confidence balancing = real_label[:, 0] + tf.pow(tf.constant(-1, dtype=tf.float32), real_label[:, 0]) * tf.constant( balancing_factor, tf.float32) modulation = tf.pow( real_label[:, 0] + tf.pow(tf.constant(-1, dtype=tf.float32), real_label[:, 0]) *
if "bn_files" in dir(): bn_params = [ np.load(bn_files[0]), np.load(bn_files[1]), np.load(bn_files[2]) ] else: bn_params = [None, None, None] outputs0, variables0, _ = tft.volume_bndo_flbias_l5_20( inputs_reshape[0], dropout_rate=0.0, batch_normalization_statistic=False, bn_params=bn_params[0]) outputs1, variables1, _ = tft.volume_bndo_flbias_l5_30( inputs_reshape[1], dropout_rate=0.0, batch_normalization_statistic=False, bn_params=bn_params[1]) outputs2, variables2, _ = tft.volume_bndo_flbias_l6_40( inputs_reshape[2], dropout_rate=0.0, batch_normalization_statistic=False, bn_params=bn_params[2]) if FUSION_MODE == 'vote': predictions = [ outputs0['sm_out'], outputs1['sm_out'], outputs2['sm_out'] ] combined_prediction = tft.vote_fusion(predictions) combined_prediction = tf.reshape(combined_prediction, [-1, 1]) elif FUSION_MODE == 'committe': predictions = [
np.load(bn_files[1]), np.load(bn_files[2]) ] else: bn_params = [None, None, None] net_outs0, variables0, _ = tft.volume_bndo_flbias_l5_20( volumes_reshape[0], False, positive_confidence, dropout_rate=0.0, batch_normalization_statistic=False, bn_params=bn_params[0]) net_outs1, variables1, _ = tft.volume_bndo_flbias_l5_30( volumes_reshape[1], False, positive_confidence, dropout_rate=0.0, batch_normalization_statistic=False, bn_params=bn_params[1]) net_outs2, variables2, _ = tft.volume_bndo_flbias_l6_40( volumes_reshape[2], False, positive_confidence, dropout_rate=0.0, batch_normalization_statistic=False, bn_params=bn_params[2]) features = [ net_outs0['flattened_out'], net_outs1['flattened_out'], net_outs2['fc1_out'] ] net_out, sm_out, fusion_variables = tft.late_fusion(features, True,