Esempio n. 1
0
    def get_distances_filename(config, gz=True):
        fields = ['data_file', 'data_index', 'segment_size', 'segment_stride', 
                  'window_size', 'window_stride', 'max_simplices', 'persistence_degree',
                  'kernel_scale', 'persistence_epsilon']
        if config.post_process != None :
            fields.extend(['post_process', 'post_process_arg'])

        return get_filename(config, fields, 'ScaleSpaceSimilarities', gz)
Esempio n. 2
0
    def get_kernel_filename(config, gz=True):
        fields = [
            'data_file', 'data_index', 'segment_size', 'segment_stride',
            'kernel_gamma'
        ]
        if config.post_process != None:
            fields.extend(['post_process', 'post_process_arg'])

        return get_filename(config, fields, 'RBFKernel', gz)
Esempio n. 3
0
    def get_distances_filename(config, gz=True):
        fields = [
            'data_file', 'data_index', 'segment_size', 'segment_stride',
            'window_size', 'window_stride', 'max_simplices',
            'persistence_degree', 'kernel_scale', 'persistence_epsilon'
        ]
        if config.post_process != None:
            fields.extend(['post_process', 'post_process_arg'])

        return get_filename(config, fields, 'ScaleSpaceSimilarities', gz)
Esempio n. 4
0
    def get_learning_filename(config, gz=True):
        fields = [
            'data_file', 'data_index', 'segment_size', 'segment_stride',
            'window_size', 'window_stride', 'learning_C', 'invariant_epsilon'
        ]
        if config.post_process != None:
            fields.extend(['post_process', 'post_process_arg'])

        return get_filename(
            config, fields,
            (config.status +
             'Learning') if config.status != None else 'FeatureLearning', gz)
Esempio n. 5
0
 def get_learning_filename(config, gz=True):
     fields = [
         'data_file', 'data_index', 'segment_size', 'segment_stride',
         'window_size', 'window_stride'
     ]
     if config.post_process != None:
         fields.extend(['post_process', 'post_process_arg'])
     if config.status == 'LandscapeDistances':
         fields.append('max_simplices')
     elif config.status == 'ScaleSpaceSimilarity':
         fields.append('max_simplices')
         fields.append('kernel_scale')
     return get_filename(
         config, fields,
         (config.status +
          'Learning') if config.status != None else 'DistanceLearning', gz)
Esempio n. 6
0
 def get_learning_filename(config, gz=True) :
     fields = ['data_file', 'data_index', 'segment_size', 'segment_stride', 'window_size', 'window_stride', 'learning_C', 'invariant_epsilon']
     if config.post_process != None :
         fields.extend(['post_process', 'post_process_arg'])
     
     return get_filename(config, fields, (config.status + 'Learning') if config.status != None else 'FeatureLearning', gz)
Esempio n. 7
0
 def get_segment_filename(config, gz=True):
     fields = ['data_file', 'data_index', 'segment_size', 'segment_stride', 'window_size', 'window_stride']
     return get_filename(config, fields, 'WalkingSegments', gz)
Esempio n. 8
0
    parser.add_argument("--infile", "-i", nargs="+")
    parser.add_argument("--outfile", "-o")
    parser.add_argument("--ratio", "-r", type=float, default=0.5)
    parser.add_argument("--pool", "-p")

    args = parser.parse_args(sys.argv[1:])
    kernels_json = [
        load_data(infile, 'kernel', None, None, sys.argv[0] + ": ")
        for infile in args.infile
    ]
    kernels = [
        Kernel.fromJSONDict(kernel_json) for kernel_json in kernels_json
    ]

    if len(kernels) == 2:
        weights = [args.ratio, 1.0 - args.ratio]
    else:
        weights = None
    average_kernel = AverageKernel(kernels, weights)

    if args.outfile == None:
        args.outfile = get_filename(average_kernel.config, [
            'max_simplices', 'persistence_epsilon', 'segment_filename',
            'segment_stride', 'segment_size', 'window_size', 'window_stride',
            'kernel_scale', 'kernel_gamma', 'invariant_epsilon', 'data_file',
            'data_index', 'label_index', 'persistence_degree', 'data_type',
            'post_process', 'post_process_arg'
        ], "AverageKernel")
    print "Writing %s" % (args.outfile, )
    save_data(args.outfile, average_kernel.toJSONDict())
Esempio n. 9
0
    kernel_matrix = [[numpy.average([k.kernel_matrix[i][j] for k in kernels]) for i in range(kernel_dimension)] for j in range(kernel_dimension)]
    return Kernel(config, kernel_matrix, segment_info)

if __name__ == "__main__" :
    parser = argparse.ArgumentParser(description="Tool to take multiple Kernels and average them")
    parser.add_argument("--infile", "-i", nargs="+")
    parser.add_argument("--outfile", "-o")
    parser.add_argument("--ratio", "-r", type=float, default=0.5)
    parser.add_argument("--pool", "-p")
    
    args = parser.parse_args(sys.argv[1:])
    kernels_json = [load_data(infile, 'kernel', None, None, sys.argv[0]+": ") for infile in args.infile]
    kernels = [Kernel.fromJSONDict(kernel_json) for kernel_json in kernels_json]

    if len(kernels) == 2 :
        weights = [args.ratio, 1.0 - args.ratio]
    else :
        weights = None
    average_kernel = AverageKernel(kernels, weights)

    if args.outfile == None :
        args.outfile = get_filename(average_kernel.config, 
                                    ['max_simplices', 'persistence_epsilon', 
                                     'segment_filename', 'segment_stride', 'segment_size', 
                                     'window_size', 'window_stride', 
                                     'kernel_scale', 'kernel_gamma', 'invariant_epsilon', 
                                     'data_file', 'data_index', 'label_index', 'persistence_degree', 
                                     'data_type', 'post_process', 'post_process_arg'], "AverageKernel")
    print "Writing %s" % (args.outfile,)
    save_data(args.outfile, average_kernel.toJSONDict())
Esempio n. 10
0
 def get_segment_filename(config, gz=True):
     fields = [
         'data_file', 'data_index', 'segment_size', 'segment_stride',
         'window_size', 'window_stride'
     ]
     return get_filename(config, fields, 'KitchenMocapSegments', False)
Esempio n. 11
0
 def get_segment_filename(config, gz=True):
     fields = [
         'data_file', 'data_index', 'segment_size', 'segment_stride',
         'window_size', 'window_stride'
     ]
     return get_filename(config, fields, 'NormalizePost', gz)
Esempio n. 12
0
 def get_segment_filename(config, gz=True):
     fields = ['data_file', 'data_index', 'segment_size',
               'segment_stride', 'window_size', 'window_stride']
     return get_filename(config, fields, 'NormalizePost', gz)
Esempio n. 13
0
 def get_distances_filename(config, gz=True):
     fields = ['data_file', 'data_index', 'segment_size', 'segment_stride', 'window_size', 'window_stride']
     if config.post_process != None :
         fields.extend(['post_process', 'post_process_arg'])
     return get_filename(config, fields, 'EuclideanDistances', gz)
Esempio n. 14
0
 def get_features_filename(config, gz=True):
     fields = ['data_file', 'data_index', 'segment_size', 'segment_stride', 'window_size', 'window_stride', 'invariant_epsilon']
     if config.post_process != None :
         fields.extend(['post_process', 'post_process_arg'])
     return get_filename(config, fields, 'ChaoticInvariantFeatures', gz)
Esempio n. 15
0
 def get_segment_filename(config, gz=True):
     fields = [
         'data_file', 'data_index', 'segment_size', 'segment_stride',
         'window_size', 'window_stride'
     ]
     return get_filename(config, fields, 'PAMAPSegments', gz)
Esempio n. 16
0
 def get_distances_filename(config, gz=True):
     fields = [
         'data_file', 'data_index', 'segment_size', 'segment_stride',
         'window_size', 'window_stride', 'max_simplices'
     ]
     return get_filename(config, fields, 'BottleneckDistances', gz)
Esempio n. 17
0
 def get_distances_filename(config, gz=True):
     fields = ['data_file', 'data_index', 'segment_size', 'segment_stride', 'window_size', 'window_stride', 'max_simplices']
     return get_filename(config, fields, 'WassersteinDistances', gz)
Esempio n. 18
0
    def get_kernel_filename(config, gz=True):
        fields = ['data_file', 'data_index', 'segment_size', 'segment_stride', 'kernel_gamma']
        if config.post_process != None :
            fields.extend(['post_process', 'post_process_arg'])

        return get_filename(config, fields, 'RBFKernel', gz)