Exemple #1
0
    def get_options_parser(cls):
        op = ConvNet.get_options_parser()
        for option in list(op.options):
            if option not in ('load_file', 'sigma'):
                op.delete_option(option)
        
        op.add_option("show-filters", "show_filters", StringOptionParser, "Show filters of specified layer", default="")
        op.add_option("norm-filters", "norm_filters", BooleanOptionParser, "Individually normalize filters shown with --show-filters", default=0)
        op.add_option("input-idx", "input_idx", IntegerOptionParser, "Input index for layer given to --show-filters", default=0)
        op.add_option("no-rgb", "no_rgb", BooleanOptionParser, "Don't combine filter channels into RGB in layer given to --show-filters", default=False)
        op.add_option("yuv-to-rgb", "yuv_to_rgb", BooleanOptionParser, "Convert RGB filters to YUV in layer given to --show-filters", default=False)
        op.add_option("channels", "channels", IntegerOptionParser, "Number of channels in layer given to --show-filters (fully-connected layers only)", default=0)
        
        op.add_option("show-cost", "show_cost", StringOptionParser, "Show specified objective function", default="")
        op.add_option("cost-idx", "cost_idx", IntegerOptionParser, "Cost function return value index for --show-cost", default=0)
        op.add_option("smooth-test-errors", "smooth_test_errors", BooleanOptionParser, "Use running average for test error plot?", default=0)
        op.add_option("output-layer", "output_layer", StringOptionParser, "Output layer that the cost is computed from", default="")
        op.add_option("show-mse", "show_mse", BooleanOptionParser, "Show mse error (or PSNR error)", default=False)
        op.add_option("step", "step", IntegerOptionParser, "Step of x axis", default=1)
        op.add_option("patch-perbatch", "patch_perbatch", IntegerOptionParser, "Num of patches per batch", default=4096)
        
        op.add_option("result-path", "result_path", StringOptionParser, "Path to store the PSNR curve", default="")

        op.options['load_file'].default = None
        return op
Exemple #2
0
    def get_options_parser(cls):
        op = ConvNet.get_options_parser()
        for option in list(op.options):
            if option not in ('gpu', 'load_file', 'train_batch_range', 'test_batch_range'):
                op.delete_option(option)
        op.add_option("show-cost", "show_cost", StringOptionParser, "Show specified objective function", default="")
        op.add_option("show-filters", "show_filters", StringOptionParser, "Show learned filters in specified layer", default="")
        op.add_option("input-idx", "input_idx", IntegerOptionParser, "Input index for layer given to --show-filters", default=0)
        op.add_option("cost-idx", "cost_idx", IntegerOptionParser, "Cost function return value index for --show-cost", default=0)
        op.add_option("no-rgb", "no_rgb", BooleanOptionParser, "Don't combine filter channels into RGB in layer given to --show-filters", default=False)
        op.add_option("yuv-to-rgb", "yuv_to_rgb", BooleanOptionParser, "Convert RGB filters to YUV in layer given to --show-filters", default=False)
        op.add_option("channels", "channels", IntegerOptionParser, "Number of channels in layer given to --show-filters (fully-connected layers only)", default=0)
        op.add_option("show-preds", "show_preds", StringOptionParser, "Show predictions made by given softmax on test set", default="")
        op.add_option("only-errors", "only_errors", BooleanOptionParser, "Show only mistaken predictions (to be used with --show-preds)", default=False, requires=['show_preds'])
        op.add_option("write-features", "write_features", StringOptionParser, "Write test data features from given layer", default="", requires=['feature-path'])
        op.add_option("feature-path", "feature_path", StringOptionParser, "Write test data features to this path (to be used with --write-features)", default="")
        
        #----my options----------
        op.add_option("hist-features", "hist_features", StringOptionParser, 
              "plot histogram of feature activation", default="")
        op.add_option("hist-test", "hist_test", BooleanOptionParser,
              "True: plot hist of test data, False: plot hist of training data", default=True )
        op.add_option("nn-analysis", "nn_analysis", StringOptionParser,
              "run inference on training mode for many times and analysis output", default="")
        #op.add_option("data-provider", "dp_type", StringOptionParser, "Data provider", default="default")
        #op.add_option("write-mv-result", "write_mv_result", StringOptionParser, "Write test data multiview features to file", default="", requires=['feature-path'])
        op.add_option("write-mv-result", "write_mv_result", StringOptionParser, "Write test data multiview features to file", default="" )
        op.add_option("write-mv-mc-result", "write_mv_mc_result", StringOptionParser, "Write test data multiview features on MC inferenceto file", default="" )


        op.options['load_file'].default = None
        return op
Exemple #3
0
 def get_options_parser(cls):
     op = ConvNet.get_options_parser()
     for option in list(op.options):
         if option not in ('gpu', 'load_file', 'train_batch_range', 'test_batch_range', 'cam_test', 'test_one'):
             op.delete_option(option)
     op.add_option("show-cost", "show_cost", StringOptionParser, "Show specified objective function", default="")
     op.add_option("show-filters", "show_filters", StringOptionParser, "Show learned filters in specified layer", default="")
     op.add_option("input-idx", "input_idx", IntegerOptionParser, "Input index for layer given to --show-filters", default=0)
     op.add_option("cost-idx", "cost_idx", IntegerOptionParser, "Cost function return value index for --show-cost", default=0)
     op.add_option("no-rgb", "no_rgb", BooleanOptionParser, "Don't combine filter channels into RGB in layer given to --show-filters", default=False)
     op.add_option("yuv-to-rgb", "yuv_to_rgb", BooleanOptionParser, "Convert RGB filters to YUV in layer given to --show-filters", default=False)
     op.add_option("channels", "channels", IntegerOptionParser, "Number of channels in layer given to --show-filters (fully-connected layers only)", default=0)
     op.add_option("show-preds", "show_preds", StringOptionParser, "Show predictions made by given softmax on test set", default="")
     op.add_option("only-errors", "only_errors", BooleanOptionParser, "Show only mistaken predictions (to be used with --show-preds)", default=False, requires=['show_preds'])
     op.add_option("write-features", "write_features", StringOptionParser, "Write test data features from given layer", default="", requires=['feature-path'])
     op.add_option("feature-path", "feature_path", StringOptionParser, "Write test data features to this path (to be used with --write-features)", default="")
     #add options here for streaming from the camera: send the results rather then save to file?
     op.add_option("show-preds-patch","show_preds_patch", StringOptionParser, "Show patch predictions made by given softmax on test set", default="")
     op.add_option("show-preds-patch-total","show_preds_patch_total", StringOptionParser, "Show patch predictions made by given softmax on test set in total image", default="")
     op.add_option("write-features-stream", "write_features_stream", StringOptionParser, "Stream test data features from given layer", default="", requires=['cam_test'])
     op.add_option("cam-test", "test_from_camera", BooleanOptionParser, "Get Test Batches from OpenNI Device?", default=0)#0? can i leave it False?
     #op.add_option("send-features", "send_features", StringOptionParser, "Send the test data features (probabilities) from given layer", default="", requires=['receiver-path'])
     #op.add_option("receiver-path", "receiver_path", StringOptionParser, "Send test data features to this (address?) (use with --send-features)", default="")
     #the above options should trigger an option in the net: test-one, and test-from-camera?: unlimited test batches, continuous until ctrl+c...
     
     op.options['load_file'].default = None
     return op
Exemple #4
0
 def get_options_parser(cls):
     op = ConvNet.get_options_parser()
     for option in list(op.options):
         if option not in ('data_path_train', 'data_path_test', 'dp_type_train', 'dp_type_test', 'gpu', 'rnorm_const', 'img_provider_file', 'load_file', 'train_batch_range', 'test_batch_range', 'verbose'):
             op.delete_option(option)
     op.add_option("test-only", "test_only", BooleanOptionParser, "Test and quit?", default=1)
     op.add_option("show-cost", "show_cost", StringOptionParser, "Show specified objective function", default="")
     op.add_option("show-filters", "show_filters", StringOptionParser, "Show learned filters in specified layer", default="")
     op.add_option("input-idx", "input_idx", IntegerOptionParser, "Input index for layer given to --show-filters", default=0)
     op.add_option("cost-idx", "cost_idx", IntegerOptionParser, "Cost function return value index for --show-cost", default=0)
     op.add_option("no-rgb", "no_rgb", BooleanOptionParser, "Don't combine filter channels into RGB in layer given to --show-filters", default=False)
     op.add_option("yuv-to-rgb", "yuv_to_rgb", BooleanOptionParser, "Convert RGB filters to YUV in layer given to --show-filters", default=False)
     op.add_option("channels", "channels", IntegerOptionParser, "Number of channels in layer given to --show-filters (fully-connected layers only)", default=0)
     op.add_option("show-preds", "show_preds", StringOptionParser, "Show predictions made by given softmax on test set", default="")
     op.add_option("only-errors", "only_errors", BooleanOptionParser, "Show only mistaken predictions (to be used with --show-preds)", default=False, requires=['show_preds'])
     op.add_option("write-features", "write_features", StringOptionParser, "Write test data features from given layer", default="", requires=['feature-path'])
     op.add_option("feature-path", "feature_path", StringOptionParser, "Write test data features to this path (to be used with --write-features)", default="")
     op.add_option("write-pixel-proj", "write_pixel_proj", StringOptionParser, "Write the projection of some response on pixel space", default = "", requires=['response_idx'])
     op.add_option("multiview", "mult_view", IntegerOptionParser, "Number of views for multi-view testing", default=1)
     op.add_option("scaleview", "scale_view", FloatOptionParser, "Scaling factor of the views in multi-view testing", default=1.0)
     op.add_option("bbxfile", "bbx_file", StringOptionParser, "Contains ground truth bounding box for each image", default="")
     op.add_option("imglist", "img_list", StringOptionParser, "Image list file", default="")
     op.add_option("clusterfile", "cluster_file", StringOptionParser, "Cluster center saved in pickle format", default="")
     op.options['load_file'].default = None
     return op
    def get_options_parser(cls):
        op = ConvNet.get_options_parser()
        for option in list(op.options):
            if option not in ('gpu', 'load_file', 'train_batch_range', 'test_batch_range', 'multiview_test'):
                op.delete_option(option)
                
        op.add_option("show-cost", "show_cost", StringOptionParser, "Show specified objective function", default="")
        op.add_option("show-filters", "show_filters", StringOptionParser, "Show learned filters in specified layer", default="")
        op.add_option("input-idx", "input_idx", IntegerOptionParser, "Input index for layer given to --show-filters", default=0)
        op.add_option("cost-idx", "cost_idx", ListOptionParser(IntegerOptionParser), "Cost function return value index for --show-cost", default=[])
#         op.add_option("cost-idx", "cost_idx", IntegerOptionParser, "Cost function return value index for --show-cost", default=0)
        op.add_option("no-rgb", "no_rgb", BooleanOptionParser, "Don't combine filter channels into RGB in layer given to --show-filters", default=False)
        op.add_option("yuv-to-rgb", "yuv_to_rgb", BooleanOptionParser, "Convert RGB filters to YUV in layer given to --show-filters", default=False)
        op.add_option("channels", "channels", IntegerOptionParser, "Number of channels in layer given to --show-filters (fully-connected layers only)", default=0)
        op.add_option("show-preds", "show_preds", IntegerOptionParser,
                      "Show predictions made by given softmax on test or predicting set. 1:test set 2:predicting set", default=0)
        op.add_option("pred-batch-range", "pred_batch_range", RangeOptionParser, "Data batch range: predicting set")
        op.add_option("logsoftmax", "logsoftmax", StringOptionParser, "name of logsoftmax typed layer", default="")
        op.add_option("only-errors", "only_errors", BooleanOptionParser, "Show only mistaken predictions (to be used with --show-preds)", default=False, requires=['show_preds'])
        
        op.add_option("write-features-train", "write_features_train", StringOptionParser, "Write train data features from given layer", default='', requires=[])
        op.add_option("write-features-test", "write_features_test", StringOptionParser, "Write test data features from given layer", default='', requires=[])
        op.add_option("write-features-pred", "write_features_pred", StringOptionParser, "Write prediction data features from given layer", default='', requires=[])        
#         op.add_option("feature-path", "feature_path", StringOptionParser, "Write test data features to this path (to be used with --write-features)", default="")
        
        op.add_option("show-layer-weights-biases", "show_layer_weights_biases", IntegerOptionParser, "Show evolution of layer-wise mean absolute of weights, weightsInc, bias, biasInc", default=0)
        
        op.add_option("confusion-mat", "confusion_mat", IntegerOptionParser, "plot confusion matrix", default=0)
        op.add_option("test-meta", "test_meta", StringOptionParser, "meta file for testing data used in plotting confusion matrix", default="")
 
        op.options['load_file'].default = None
        return op
Exemple #6
0
 def get_options_parser(cls):
     op = ConvNet.get_options_parser()
     for option in list(op.options):
         if option not in ('gpu', 'load_file', 'train_batch_range', 'test_batch_range', 'data_path', 'minibatch_size', 'layer_params', 'batch_size', 'test_only', 'test_one', 'shuffle_data', 'crop_one_border', 'external_meta_path'):
             op.delete_option(option)
     op.add_option('mode', 'mode', StringOptionParser, "The mode for evaluation")
     op.add_option('images-folder', 'images_folder', StringOptionParser, 'The folder for testing images')
     op.add_option('mean-image-path', 'mean_image_path', StringOptionParser, 'The path for mean image')
     op.options['load_file'].default = None
     return op
 def get_options_parser(cls):
     op = ConvNet.get_options_parser()
     for option in list(op.options):
         if option not in ('gpu', 'load_file', 'train_batch_range', 'test_batch_range', 'data_path', 'minibatch_size', 'layer_params', 'batch_size', 'test_only', 'test_one', 'shuffle_data', 'crop_one_border'):
             op.delete_option(option)
     op.add_option('do-pose-evaluation', 'do_pose_evaluation', StringOptionParser, 'Specify the output layer of pose')
     op.add_option('inputstream', 'inputstream', StringOptionParser, 'Specify the type of camera to use [imgcamera|cvcamera]')
     op.add_option('outputdir', 'outputdir', StringOptionParser, 'Specify the directory for saving outputs')
     op.add_option('crop-image', 'crop_image', StringOptionParser, 'Specify the method to crop image to square input patch [faceubd]') 
     op.options['load_file'].default = None
     return op
    def get_options_parser(cls):
        op = ConvNet.get_options_parser()
        for option in list(op.options):
            if option not in ('gpu', 'load_file', 'train_batch_range', 'test_batch_range',
                              'minibatch_size', 'data_path', 'dp_type'):
                op.delete_option(option)
        op.add_option("show-cost", "show_cost", StringOptionParser,
                      "Show specified objective function", default="")
        op.add_option("show-filters", "show_filters", StringOptionParser,
                      "Show learned filters in specified layer", default="")
        op.add_option("input-idx", "input_idx", IntegerOptionParser,
                      "Input index for layer given to --show-filters", default=0)
        op.add_option("cost-idx", "cost_idx", IntegerOptionParser,
                      "Cost function return value index for --show-cost", default=0)
        op.add_option("no-rgb", "no_rgb", BooleanOptionParser,
                      "Don't combine filter channels into RGB in layer given to --show-filters",
                      default=False)
        op.add_option("yuv-to-rgb", "yuv_to_rgb", BooleanOptionParser,
                      "Convert RGB filters to YUV in layer given to --show-filters",
                      default=False)
        op.add_option("channels", "channels", IntegerOptionParser,
                      "Number of channels in layer given to --show-filters \
                      (fully-connected layers only)", default=0)
        op.add_option("show-preds", "show_preds", StringOptionParser,
                      "Show predictions made by given softmax on test set", default="")
        op.add_option("only-errors", "only_errors", BooleanOptionParser,
                      "Show only mistaken predictions (to be used with --show-preds)",
                      default=False, requires=['show_preds'])
        op.add_option("write-features", "write_features", StringOptionParser,
                      "Write test data features from given layer",
                      default="", requires=['feature-path'])
        op.add_option("feature-path", "feature_path", StringOptionParser,
                      "Write test data features to this path (to be used with --write-features)",
                      default="")

        op.add_option("show-layers", "show_layers", StringOptionParser,
                      "Show configurations of a layer", default="")
        op.add_option("output-one", "output_one", BooleanOptionParser,
                      "Output to one file", default=False)
        op.add_option("feature-file", "feature_file", StringOptionParser,
                      "Write test data features to this file (to be used with --output-one)",
                      default="")
        op.add_option("write-predictions", "write_predictions", StringOptionParser,
                      "Write predictions to a file", default="")
        # requires=['logreg_name']
        op.add_option("multiview-test", "multiview_test", BooleanOptionParser,
                      "Cropped DP: test on multiple patches?", default=False)

        op.options['load_file'].default = None
        return op
Exemple #9
0
 def get_options_parser(cls):
     op = ConvNet.get_options_parser()
     for option in list(op.options):
         if option not in ('gpu', 'load_file', 'train_batch_range',
                           'test_batch_range', 'data_path',
                           'minibatch_size', 'layer_params', 'batch_size',
                           'test_only', 'test_one', 'shuffle_data',
                           'crop_one_border', 'external_meta_path'):
             op.delete_option(option)
     op.add_option('mode', 'mode', StringOptionParser,
                   "The mode for evaluation")
     op.add_option('images-folder', 'images_folder', StringOptionParser,
                   'The folder for testing images')
     op.add_option('mean-image-path', 'mean_image_path', StringOptionParser,
                   'The path for mean image')
     op.options['load_file'].default = None
     return op
Exemple #10
0
    def get_options_parser(cls):
        op = ConvNet.get_options_parser()
        op.add_option("epochs2",
                      "num_epochs2",
                      IntegerOptionParser,
                      "Number of epochs with noise learning",
                      default=0)
        op.add_option("noise-eps",
                      "noise_eps",
                      FloatOptionParser,
                      "Learning rate of noise matrix",
                      default=0.001)
        op.add_option("noise-wc",
                      "noise_wc",
                      FloatOptionParser,
                      "Weight cost on noise matrix",
                      default=0.1)
        op.add_option("noise-level",
                      "noise_level",
                      FloatOptionParser,
                      "Amount of incorrect training labels",
                      default=0.0)
        op.add_option("noise-true",
                      "noise_true",
                      BooleanOptionParser,
                      "Use true noise matrix",
                      default=0)
        op.add_option("noise-Qpath",
                      "noise_Qpath",
                      StringOptionParser,
                      "Path to noise matrix Q",
                      default="data/mixing-offdiag-2.npy")

        op.options["dp_type"].default = "cifar"
        op.options["data_path"].default = "/home/sainbar/data/cifar-10/train"
        op.options["save_path"].default = "/tmp/cifar-10/"
        op.options["test_batch_range"].default = [6]
        op.options[
            "layer_def"].default = "./example-layers/layers-18pct-noisy.cfg"
        op.options[
            "layer_params"].default = "./example-layers/layer-params-18pct-noisy.cfg"
        op.options["testing_freq"].default = 10

        return op
 def get_options_parser(cls):
     op = ConvNet.get_options_parser()
     for option in list(op.options):
         if option not in ('gpu', 'load_file', 'train_batch_range', 'test_batch_range'):
             op.delete_option(option)
     op.add_option("show-cost", "show_cost", StringOptionParser, "Show specified objective function", default="")
     op.add_option("show-filters", "show_filters", StringOptionParser, "Show learned filters in specified layer", default="")
     op.add_option("input-idx", "input_idx", IntegerOptionParser, "Input index for layer given to --show-filters", default=0)
     op.add_option("cost-idx", "cost_idx", IntegerOptionParser, "Cost function return value index for --show-cost", default=0)
     op.add_option("no-rgb", "no_rgb", BooleanOptionParser, "Don't combine filter channels into RGB in layer given to --show-filters", default=False)
     op.add_option("yuv-to-rgb", "yuv_to_rgb", BooleanOptionParser, "Convert RGB filters to YUV in layer given to --show-filters", default=False)
     op.add_option("channels", "channels", IntegerOptionParser, "Number of channels in layer given to --show-filters (fully-connected layers only)", default=0)
     op.add_option("show-preds", "show_preds", StringOptionParser, "Show predictions made by given softmax on test set", default="")
     op.add_option("only-errors", "only_errors", BooleanOptionParser, "Show only mistaken predictions (to be used with --show-preds)", default=False, requires=['show_preds'])
     op.add_option("write-features", "write_features", StringOptionParser, "Write test data features from given layer", default="", requires=['feature-path'])
     op.add_option("feature-path", "feature_path", StringOptionParser, "Write test data features to this path (to be used with --write-features)", default="")
     
     op.options['load_file'].default = None
     return op
 def get_options_parser(cls):
     op = ConvNet.get_options_parser()
     for option in list(op.options):
         if option not in ('gpu', 'load_file', 'train_batch_range', 'test_batch_range'):
             op.delete_option(option)
     op.add_option("show-cost", "show_cost", StringOptionParser, "Show specified objective function", default="")
     op.add_option("show-filters", "show_filters", StringOptionParser, "Show learned filters in specified layer", default="")
     op.add_option("input-idx", "input_idx", IntegerOptionParser, "Input index for layer given to --show-filters", default=0)
     op.add_option("cost-idx", "cost_idx", IntegerOptionParser, "Cost function return value index for --show-cost", default=0)
     op.add_option("no-rgb", "no_rgb", BooleanOptionParser, "Don't combine filter channels into RGB in layer given to --show-filters", default=False)
     op.add_option("yuv-to-rgb", "yuv_to_rgb", BooleanOptionParser, "Convert RGB filters to YUV in layer given to --show-filters", default=False)
     op.add_option("channels", "channels", IntegerOptionParser, "Number of channels in layer given to --show-filters (fully-connected layers only)", default=0)
     op.add_option("show-preds", "show_preds", StringOptionParser, "Show predictions made by given softmax on test set", default="")
     op.add_option("only-errors", "only_errors", BooleanOptionParser, "Show only mistaken predictions (to be used with --show-preds)", default=False, requires=['show_preds'])
     op.add_option("write-features", "write_features", StringOptionParser, "Write test data features from given layer", default="", requires=['feature-path'])
     op.add_option("feature-path", "feature_path", StringOptionParser, "Write test data features to this path (to be used with --write-features)", default="")
     op.add_option("save-to-file", "save_to_file", StringOptionParser, "Save the plot to file", default="")
     
     op.options['load_file'].default = None
     return op
    def get_options_parser(cls):
        op = ConvNet.get_options_parser()
        for option in list(op.options):
            if option not in ('gpu', 'load_file', 'inner_size', 'train_batch_range', 'test_batch_range', 'multiview_test', 'data_path', 'pca_noise', 'scalar_mean'):
                op.delete_option(option)
        op.add_option("show-cost", "show_cost", StringOptionParser, "Show specified objective function", default="")
        op.add_option("show-filters", "show_filters", StringOptionParser, "Show learned filters in specified layer", default="")
        op.add_option("norm-filters", "norm_filters", BooleanOptionParser, "Individually normalize filters shown with --show-filters", default=0)
        op.add_option("input-idx", "input_idx", IntegerOptionParser, "Input index for layer given to --show-filters", default=0)
        op.add_option("cost-idx", "cost_idx", IntegerOptionParser, "Cost function return value index for --show-cost", default=0)
        op.add_option("no-rgb", "no_rgb", BooleanOptionParser, "Don't combine filter channels into RGB in layer given to --show-filters", default=False)
        op.add_option("yuv-to-rgb", "yuv_to_rgb", BooleanOptionParser, "Convert RGB filters to YUV in layer given to --show-filters", default=False)
        op.add_option("channels", "channels", IntegerOptionParser, "Number of channels in layer given to --show-filters (fully-connected layers only)", default=0)
        op.add_option("show-preds", "show_preds", StringOptionParser, "Show predictions made by given softmax on test set", default="")
        op.add_option("save-preds", "save_preds", StringOptionParser, "Save predictions to given path instead of showing them", default="")
        op.add_option("only-errors", "only_errors", BooleanOptionParser, "Show only mistaken predictions (to be used with --show-preds)", default=False, requires=['show_preds'])
        op.add_option("local-plane", "local_plane", IntegerOptionParser, "Local plane to show", default=0)
        op.add_option("smooth-test-errors", "smooth_test_errors", BooleanOptionParser, "Use running average for test error plot?", default=1)

        op.options['load_file'].default = None
        return op
 def get_options_parser(cls):
     op = ConvNet.get_options_parser()
     for option in list(op.options):
         if option not in ('gpu', 'load_file', 'train_batch_range',
                           'test_batch_range', 'data_path',
                           'minibatch_size', 'layer_params', 'batch_size',
                           'test_only', 'test_one', 'shuffle_data',
                           'crop_one_border'):
             op.delete_option(option)
     op.add_option('do-pose-evaluation', 'do_pose_evaluation',
                   StringOptionParser, 'Specify the output layer of pose')
     op.add_option(
         'inputstream', 'inputstream', StringOptionParser,
         'Specify the type of camera to use [imgcamera|cvcamera]')
     op.add_option('outputdir', 'outputdir', StringOptionParser,
                   'Specify the directory for saving outputs')
     op.add_option(
         'crop-image', 'crop_image', StringOptionParser,
         'Specify the method to crop image to square input patch [faceubd]')
     op.options['load_file'].default = None
     return op
Exemple #15
0
    def get_op(self, n_epochs=None, params_file=None,
               train_range='1-5', test_range='6'):
        from convnet import ConvNet
        op = ConvNet.get_options_parser()
        load_dic = None

        for option in op.get_options_list():
            option.set_default()

        op.set_value('data_path',
                     os.path.expanduser('~/data/cifar-10-py-colmajor/'))
        op.set_value('dp_type', 'cifar')
        op.set_value('inner_size', '24')

        op.set_value('gpu', '0')
        op.set_value('testing_freq', '25')

        op.set_value('layer_path', 'layers/')
        op.set_value('layer_def', self.network_type.layer_file)
        op.set_value('layer_params',
                     params_file or self.network_type.layer_params_file)

        op.set_value('train_batch_range', train_range)
        op.set_value('test_batch_range', test_range)
        if n_epochs is not None:
            op.set_value('num_epochs', n_epochs, parse=False)

        checkpoint_path = os.path.join(save_dir, self.checkpoint_name())
        if os.path.exists(checkpoint_path):
            op.set_value('load_file', checkpoint_path)
            load_dic = ConvNet.load_checkpoint(checkpoint_path)
            old_op = load_dic['op']
            old_options = dict(old_op.options)
            old_op.merge_from(op)
            op.options, old_op.options = old_op.options, old_options
        else:
            op.set_value('save_file_override', checkpoint_path)

        return op, load_dic
Exemple #16
0
    def get_options_parser(cls):
        op = ConvNet.get_options_parser()
        for option in list(op.options):
            if option not in ('gpu', 'load_file', 'inner_size',
                              'train_batch_range', 'test_batch_range',
                              'multiview_test', 'data_path', 'pca_noise',
                              'scalar_mean'):
                op.delete_option(option)
        op.add_option("show-cost",
                      "show_cost",
                      StringOptionParser,
                      "Show specified objective function",
                      default="")
        op.add_option("show-filters",
                      "show_filters",
                      StringOptionParser,
                      "Show learned filters in specified layer",
                      default="")
        op.add_option(
            "norm-filters",
            "norm_filters",
            BooleanOptionParser,
            "Individually normalize filters shown with --show-filters",
            default=0)
        op.add_option("input-idx",
                      "input_idx",
                      IntegerOptionParser,
                      "Input index for layer given to --show-filters",
                      default=0)
        op.add_option("cost-idx",
                      "cost_idx",
                      IntegerOptionParser,
                      "Cost function return value index for --show-cost",
                      default=0)
        op.add_option(
            "no-rgb",
            "no_rgb",
            BooleanOptionParser,
            "Don't combine filter channels into RGB in layer given to --show-filters",
            default=False)
        op.add_option(
            "yuv-to-rgb",
            "yuv_to_rgb",
            BooleanOptionParser,
            "Convert RGB filters to YUV in layer given to --show-filters",
            default=False)
        op.add_option(
            "channels",
            "channels",
            IntegerOptionParser,
            "Number of channels in layer given to --show-filters (fully-connected layers only)",
            default=0)
        op.add_option("show-preds",
                      "show_preds",
                      StringOptionParser,
                      "Show predictions made by given softmax on test set",
                      default="")
        op.add_option("save-preds",
                      "save_preds",
                      StringOptionParser,
                      "Save predictions to given path instead of showing them",
                      default="")
        op.add_option(
            "only-errors",
            "only_errors",
            BooleanOptionParser,
            "Show only mistaken predictions (to be used with --show-preds)",
            default=False,
            requires=['show_preds'])
        op.add_option("local-plane",
                      "local_plane",
                      IntegerOptionParser,
                      "Local plane to show",
                      default=0)
        op.add_option("smooth-test-errors",
                      "smooth_test_errors",
                      BooleanOptionParser,
                      "Use running average for test error plot?",
                      default=1)
        op.add_option("save_figure",
                      "save_figure",
                      StringOptionParser,
                      "Output file to save filters",
                      default="")

        op.options['load_file'].default = None
        return op
Exemple #17
0
""" View the options used to create a checkpoint

    python view_options.py --load-file <checkpoint>
"""
from convnet import ConvNet
from python_util.gpumodel import IGPUModel

op = ConvNet.get_options_parser()

op, load_dic = IGPUModel.parse_options(op)
model = ConvNet(op, load_dic)

model.op.print_values()
print "========================="
model.print_model_state()
Exemple #18
0
def objective(layer_file_name, param_file_name, save_file_name):
    def logprob_errors(error_output):
        error_types, n = error_output
        logprob = error_types['logprob'][0] / n
        classifier = error_types['logprob'][1] / n
        logprob = np.inf if np.isnan(logprob) else logprob
        classifier = np.inf if np.isnan(classifier) else classifier
        return logprob, classifier

    real_stdout = sys.stdout
    sys.stdout = open(save_file_name + '.log', 'w')
    convnet = None
    try:
        # set up options
        op = ConvNet.get_options_parser()

        for option in op.get_options_list():
            option.set_default()

        op.set_value('data_path', os.path.expanduser('~/data/cifar-10-py-colmajor/'))
        op.set_value('dp_type', 'cifar')
        op.set_value('inner_size', '24')

        op.set_value('gpu', '0')
        op.set_value('testing_freq', '25')

        op.set_value('train_batch_range', '1-5')
        op.set_value('test_batch_range', '6')
        op.set_value('num_epochs', n_epochs, parse=False)

        op.set_value('layer_def', layer_file_name)
        op.set_value('layer_params', param_file_name)
        op.set_value('save_file_override', save_file_name)

        convnet = ConvNet(op, None)

        # train for three epochs and make sure error is okay
        convnet.num_epochs = 3
        convnet.train()

        logprob, error = logprob_errors(convnet.train_outputs[-1])
        if not (error > 0 and error < 0.85):
            # should get at most 85% error after three epochs
            print "\naborted (%s, %s)" % (logprob, error)
            return logprob, error

        # train for full epochs
        convnet.num_epochs = n_epochs
        convnet.train()

        logprob, error = logprob_errors(convnet.get_test_error())
        print "\nfinished (%s, %s)" % (logprob, error)

        return logprob, error
    except RuntimeError:
        print "\nerrored at epoch %d" % (convnet.epoch)
        return np.inf, 1.0
    finally:
        if convnet is not None:
            convnet.destroy_model_lib()

        print "\n"  # end any pending lines to ensure flush
        sys.stdout.flush()
        sys.stdout.close()
        sys.stdout = real_stdout
Exemple #19
0
 def get_options_parser(cls):
     op = ConvNet.get_options_parser()
     for option in list(op.options):
         if option not in ('gpu', 'load_file'):
             op.delete_option(option)
     return op
Exemple #20
0
    def get_options_parser(cls):
        op = ConvNet.get_options_parser()
        for option in list(op.options):
            if option not in ('gpu', 'load_file', 'train_batch_range',
                              'test_batch_range'):
                op.delete_option(option)
        op.add_option("show-cost",
                      "show_cost",
                      StringOptionParser,
                      "Show specified objective function",
                      default="")
        op.add_option("show-filters",
                      "show_filters",
                      StringOptionParser,
                      "Show learned filters in specified layer",
                      default="")
        op.add_option("input-idx",
                      "input_idx",
                      IntegerOptionParser,
                      "Input index for layer given to --show-filters",
                      default=0)
        op.add_option("cost-idx",
                      "cost_idx",
                      IntegerOptionParser,
                      "Cost function return value index for --show-cost",
                      default=0)
        op.add_option(
            "no-rgb",
            "no_rgb",
            BooleanOptionParser,
            "Don't combine filter channels into RGB in layer given to --show-filters",
            default=False)
        op.add_option(
            "yuv-to-rgb",
            "yuv_to_rgb",
            BooleanOptionParser,
            "Convert RGB filters to YUV in layer given to --show-filters",
            default=False)
        op.add_option(
            "channels",
            "channels",
            IntegerOptionParser,
            "Number of channels in layer given to --show-filters (fully-connected layers only)",
            default=0)
        op.add_option("show-preds",
                      "show_preds",
                      StringOptionParser,
                      "Show predictions made by given softmax on test set",
                      default="")
        op.add_option(
            "only-errors",
            "only_errors",
            BooleanOptionParser,
            "Show only mistaken predictions (to be used with --show-preds)",
            default=False,
            requires=['show_preds'])
        op.add_option("write-features",
                      "write_features",
                      StringOptionParser,
                      "Write test data features from given layer",
                      default="",
                      requires=['feature-path'])
        op.add_option(
            "feature-path",
            "feature_path",
            StringOptionParser,
            "Write test data features to this path (to be used with --write-features)",
            default="")

        #----my options----------
        op.add_option("hist-features",
                      "hist_features",
                      StringOptionParser,
                      "plot histogram of feature activation",
                      default="")
        op.add_option(
            "hist-test",
            "hist_test",
            BooleanOptionParser,
            "True: plot hist of test data, False: plot hist of training data",
            default=True)
        op.add_option(
            "nn-analysis",
            "nn_analysis",
            StringOptionParser,
            "run inference on training mode for many times and analysis output",
            default="")
        #op.add_option("data-provider", "dp_type", StringOptionParser, "Data provider", default="default")
        #op.add_option("write-mv-result", "write_mv_result", StringOptionParser, "Write test data multiview features to file", default="", requires=['feature-path'])
        op.add_option("write-mv-result",
                      "write_mv_result",
                      StringOptionParser,
                      "Write test data multiview features to file",
                      default="")
        op.add_option(
            "write-mv-mc-result",
            "write_mv_mc_result",
            StringOptionParser,
            "Write test data multiview features on MC inferenceto file",
            default="")

        op.options['load_file'].default = None
        return op
Exemple #21
0
    def get_options_parser(cls):
        op = ConvNet.get_options_parser()
        for option in list(op.options):
            if option not in ('gpu', 'load_file', 'train_batch_range',
                              'test_batch_range', 'multiview_test'):
                op.delete_option(option)

        op.add_option("show-cost",
                      "show_cost",
                      StringOptionParser,
                      "Show specified objective function",
                      default="")
        op.add_option("show-filters",
                      "show_filters",
                      StringOptionParser,
                      "Show learned filters in specified layer",
                      default="")
        op.add_option("input-idx",
                      "input_idx",
                      IntegerOptionParser,
                      "Input index for layer given to --show-filters",
                      default=0)
        op.add_option("cost-idx",
                      "cost_idx",
                      ListOptionParser(IntegerOptionParser),
                      "Cost function return value index for --show-cost",
                      default=[])
        #         op.add_option("cost-idx", "cost_idx", IntegerOptionParser, "Cost function return value index for --show-cost", default=0)
        op.add_option(
            "no-rgb",
            "no_rgb",
            BooleanOptionParser,
            "Don't combine filter channels into RGB in layer given to --show-filters",
            default=False)
        op.add_option(
            "yuv-to-rgb",
            "yuv_to_rgb",
            BooleanOptionParser,
            "Convert RGB filters to YUV in layer given to --show-filters",
            default=False)
        op.add_option(
            "channels",
            "channels",
            IntegerOptionParser,
            "Number of channels in layer given to --show-filters (fully-connected layers only)",
            default=0)
        op.add_option(
            "show-preds",
            "show_preds",
            IntegerOptionParser,
            "Show predictions made by given softmax on test or predicting set. 1:test set 2:predicting set",
            default=0)
        op.add_option("pred-batch-range", "pred_batch_range",
                      RangeOptionParser, "Data batch range: predicting set")
        op.add_option("logsoftmax",
                      "logsoftmax",
                      StringOptionParser,
                      "name of logsoftmax typed layer",
                      default="")
        op.add_option(
            "only-errors",
            "only_errors",
            BooleanOptionParser,
            "Show only mistaken predictions (to be used with --show-preds)",
            default=False,
            requires=['show_preds'])

        op.add_option("write-features-train",
                      "write_features_train",
                      StringOptionParser,
                      "Write train data features from given layer",
                      default='',
                      requires=[])
        op.add_option("write-features-test",
                      "write_features_test",
                      StringOptionParser,
                      "Write test data features from given layer",
                      default='',
                      requires=[])
        op.add_option("write-features-pred",
                      "write_features_pred",
                      StringOptionParser,
                      "Write prediction data features from given layer",
                      default='',
                      requires=[])
        #         op.add_option("feature-path", "feature_path", StringOptionParser, "Write test data features to this path (to be used with --write-features)", default="")

        op.add_option(
            "show-layer-weights-biases",
            "show_layer_weights_biases",
            IntegerOptionParser,
            "Show evolution of layer-wise mean absolute of weights, weightsInc, bias, biasInc",
            default=0)

        op.add_option("confusion-mat",
                      "confusion_mat",
                      IntegerOptionParser,
                      "plot confusion matrix",
                      default=0)
        op.add_option(
            "test-meta",
            "test_meta",
            StringOptionParser,
            "meta file for testing data used in plotting confusion matrix",
            default="")

        op.options['load_file'].default = None
        return op
Exemple #22
0
    def get_options_parser(cls):
        op = ConvNet.get_options_parser()
        for option in list(op.options):
            if option not in ('load_file', 'sigma'):
                op.delete_option(option)

        op.add_option("show-filters",
                      "show_filters",
                      StringOptionParser,
                      "Show filters of specified layer",
                      default="")
        op.add_option(
            "norm-filters",
            "norm_filters",
            BooleanOptionParser,
            "Individually normalize filters shown with --show-filters",
            default=0)
        op.add_option("input-idx",
                      "input_idx",
                      IntegerOptionParser,
                      "Input index for layer given to --show-filters",
                      default=0)
        op.add_option(
            "no-rgb",
            "no_rgb",
            BooleanOptionParser,
            "Don't combine filter channels into RGB in layer given to --show-filters",
            default=False)
        op.add_option(
            "yuv-to-rgb",
            "yuv_to_rgb",
            BooleanOptionParser,
            "Convert RGB filters to YUV in layer given to --show-filters",
            default=False)
        op.add_option(
            "channels",
            "channels",
            IntegerOptionParser,
            "Number of channels in layer given to --show-filters (fully-connected layers only)",
            default=0)

        op.add_option("show-cost",
                      "show_cost",
                      StringOptionParser,
                      "Show specified objective function",
                      default="")
        op.add_option("cost-idx",
                      "cost_idx",
                      IntegerOptionParser,
                      "Cost function return value index for --show-cost",
                      default=0)
        op.add_option("smooth-test-errors",
                      "smooth_test_errors",
                      BooleanOptionParser,
                      "Use running average for test error plot?",
                      default=0)
        op.add_option("output-layer",
                      "output_layer",
                      StringOptionParser,
                      "Output layer that the cost is computed from",
                      default="")
        op.add_option("show-mse",
                      "show_mse",
                      BooleanOptionParser,
                      "Show mse error (or PSNR error)",
                      default=False)
        op.add_option("step",
                      "step",
                      IntegerOptionParser,
                      "Step of x axis",
                      default=1)
        op.add_option("patch-perbatch",
                      "patch_perbatch",
                      IntegerOptionParser,
                      "Num of patches per batch",
                      default=4096)

        op.add_option("result-path",
                      "result_path",
                      StringOptionParser,
                      "Path to store the PSNR curve",
                      default="")

        op.options['load_file'].default = None
        return op
 def get_options_parser(cls):
     op = ConvNet.get_options_parser()
     op.add_option("test-on-images", "test_on_images", BooleanOptionParser, "Test On Images", default=False)
     return op