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)
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)
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)
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)
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)
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)
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)
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())
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())
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)
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)
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)
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)
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)
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)
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)
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)
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)