Beispiel #1
0
def matrix_regression_data_prepare(**kwargs):
    bufferCollection = buffers.BufferCollection()
    bufferCollection.AddBuffer(buffers.X_FLOAT_DATA,
                               buffers.as_matrix_buffer(kwargs['x']))
    if 'y' in kwargs:
        bufferCollection.AddBuffer(buffers.YS,
                                   buffers.as_matrix_buffer(kwargs['y']))
    return bufferCollection
def depth_delta_classification_data_prepare(**kwargs):
    bufferCollection = buffers.BufferCollection()
    bufferCollection.AddBuffer(buffers.DEPTH_IMAGES, kwargs['depth_images'])
    bufferCollection.AddBuffer(buffers.PIXEL_INDICES, kwargs['pixel_indices'])
    if 'offset_scales' in kwargs:
        bufferCollection.AddBuffer(buffers.OFFSET_SCALES,
                                   kwargs['offset_scales'])
    if 'classes' in kwargs:
        bufferCollection.AddBuffer(buffers.CLASS_LABELS, kwargs['classes'])
    return bufferCollection
def depth_delta_regression_data_prepare(**kwargs):
    bufferCollection = buffers.BufferCollection()
    bufferCollection.AddBuffer(buffers.DEPTH_IMAGES, kwargs['depth_images'])
    bufferCollection.AddBuffer(buffers.PIXEL_INDICES, kwargs['pixel_indices'])
    if 'offset_scales' in kwargs:
        bufferCollection.AddBuffer(buffers.OFFSET_SCALES,
                                   kwargs['offset_scales'])
    if 'y' in kwargs:
        bufferCollection.AddBuffer(buffers.YS, kwargs['y'])
    return bufferCollection
Beispiel #4
0
    def predict_proba(self, x):
        buffer_collection = buffers.BufferCollection()
        buffer_collection.AddFloat32MatrixBuffer(buffers.X_FLOAT_DATA, buffers.as_matrix_buffer(x))

        number_of_classes = self.forest_data.GetTree(0).GetYs().GetN()
        all_samples_step = pipeline.AllSamplesStep_f32f32i32(buffers.X_FLOAT_DATA)
        combiner = classification.ClassProbabilityCombiner_f32(number_of_classes)
        matrix_feature = matrix_features.LinearFloat32MatrixFeature_f32i32(all_samples_step.IndicesBufferId,
                                                                            buffers.X_FLOAT_DATA)
        forest_predicter = predict.LinearMatrixClassificationPredictin_f32i32(forest_data, matrix_feature, combiner, all_samples_step)

        result = buffers.Float32MatrixBuffer()
        forest_predicter.PredictYs(bufferCollection, result)
        return buffers.as_numpy_array(result)
def matrix_classification_data_prepare(**kwargs):
    bufferCollection = buffers.BufferCollection()
    bufferCollection.AddBuffer(buffers.X_FLOAT_DATA, kwargs['x'])
    if 'classes' in kwargs:
        bufferCollection.AddBuffer(buffers.CLASS_LABELS, kwargs['classes'])
    return bufferCollection
Beispiel #6
0
                "%s%s.exr" % (args.pose_files_input_path, pose_filename))
            labels = kinect_utils.load_labels_from_png(
                "%s%s.png" % (args.pose_files_input_path, pose_filename))
            pixel_indices, pixel_labels = kinect_utils.sample_pixels_from_image(
                labels[0, :, :], config.number_of_pixels_per_image)

            # Randomly sample pixels and offset scales
            (number_of_datapoints, _) = pixel_indices.shape
            offset_scales = np.array(np.random.uniform(
                0.8, 1.2, (number_of_datapoints, 2)),
                                     dtype=np.float32)
            datapoint_indices = np.array(np.arange(number_of_datapoints),
                                         dtype=np.int32)

            # Package buffers for learner
            bufferCollection = buffers.BufferCollection()
            bufferCollection.AddFloat32Tensor3Buffer(
                buffers.DEPTH_IMAGES, buffers.as_tensor_buffer(depths))
            bufferCollection.AddFloat32MatrixBuffer(
                buffers.OFFSET_SCALES, buffers.as_matrix_buffer(offset_scales))
            bufferCollection.AddInt32MatrixBuffer(
                buffers.PIXEL_INDICES, buffers.as_matrix_buffer(pixel_indices))
            bufferCollection.AddInt32VectorBuffer(
                buffers.CLASS_LABELS, buffers.as_vector_buffer(pixel_labels))

            # Update learner
            online_learner.Train(bufferCollection,
                                 buffers.Int32Vector(datapoint_indices))

            #pickle forest and data used for training
            if (i + 1) % 1 == 0: