コード例 #1
0
    

    numParts = args.numParts
    numExtensionParts = args.numExtensionParts
    extensionPatchSize = args.extensionPatchSize

    if args.log:
        from pnet.vzlog import default as vz
    ag.set_verbose(True)
    
    sup_ims = []
    sup_labels = []
    net = pnet.PartsNet.load(args.lowerPartsModel)
    layers = [
        #pnet.IntensityThresholdLayer(),
        pnet.ExtensionPartsLayer(num_parts = numParts, num_components = numExtensionParts, part_shape = (extensionPatchSize, extensionPatchSize), lowerLayerShape = (6,6)) 
    ]
    clnet = pnet.PartsNet([net] + layers)


    ims, label = ag.io.load_cifar10('training')

    clnet.train(ims)
    clnet.save(args.model)

'''
    classes = range(10)
    classificationTraining = 5000
    rs = np.random.RandomState(training_seed)
    for d in classes:
        ims0,tmpLabel = ag.io.load_cifar10('training', classes = [d])
コード例 #2
0
    ag.set_verbose(True)
    
    sup_ims = []
    sup_labels = []
    net = None
    layers = [
        #pnet.IntensityThresholdLayer(),
        
        pnet.EdgeLayer(k=5, radius=1, spread='orthogonal', minimum_contrast=0.05),
        pnet.PartsLayer(100, (6, 6), settings=dict(outer_frame=0,
                                                  threshold=40, 
                                                  samples_per_image=40, 
                                                  max_samples=1000000, 
                                                  min_prob=0.005,
                                                  )),
        pnet.ExtensionPartsLayer(num_parts = 100, num_components = 10, part_shape = (12,12), lowerLayerShape = (6,6)),        
        pnet.PoolingLayer(shape=(4,4), strides=(4, 4)),
        pnet.MixtureClassificationLayer(n_components=1, min_prob=0.0001,block_size=200),
        #pnet.SVMClassificationLayer(C=None)
    ]

    net = pnet.PartsNet(layers)

    digits = range(10)
    ims = ag.io.load_mnist('training', selection=slice(10000), return_labels=False)

    net.train(ims)
    
    #sup_ims = []
    #sup_labels = []
コード例 #3
0
                            radius=1,
                            spread='orthogonal',
                            minimum_contrast=0.05),
        pnet.PartsLayer(100, (3, 3),
                        settings=dict(
                            outer_frame=0,
                            threshold=10,
                            samples_per_image=20,
                            max_samples=1000000,
                            min_prob=0.005,
                        )),

        #pnet.PoolingLayer(shape=(4,4), strides=(4, 4)),
        #pnet.MixtureClassificationLayer(n_components=1, min_prob=0.0001,block_size=200),
        pnet.ExtensionPartsLayer(num_parts=100,
                                 num_components=10,
                                 part_shape=(9, 9),
                                 lowerLayerShape=(3, 3)),
        #pnet.ExtensionPoolingLayer(n_parts = 1000, grouping_type = 'rbm', pooling_type = 'distance', pooling_distance = 5, weights_file = None, save_weights_file = None, settings = {})
        pnet.PoolingLayer(shape=(4, 4), strides=(4, 4)),
        pnet.SVMClassificationLayer(C=None)
    ]

    net = pnet.PartsNet(layers)

    ims, label = ag.io.load_cifar10('training', selection=slice(0, 1000))

    net.train(ims)

    classes = range(10)
    classificationTraining = 10
    rs = np.random.RandomState(training_seed)