示例#1
0
def create_classifer(in_path,out_path,built_classifer,flat=True):
    dataset=load.get_images(in_path)
    cls=built_classifer(dataset.shape())
    print(flat)
    if(flat):
        cls=learning_iter(dataset,cls)
    else:
        cls=learning_conv(dataset,cls)
    utils.save_object(out_path,cls)
    return cls
示例#2
0
    return T.maximum(X, 0.)

def dropout(X, p=0.):
    if p > 0:
        retain_prob = 1 - p
        X *= srng.binomial(X.shape, p=retain_prob, dtype=theano.config.floatX)
        X /= retain_prob
    return X

def softmax(X):
    e_x = T.exp(X - X.max(axis=1).dimshuffle(0, 'x'))
    return e_x / e_x.sum(axis=1).dimshuffle(0, 'x')

def get_hyper_params(learning_rate=0.10):
    kern_one=8#32
    kern_two=12#64
    kern_third=16#128
    n_hidden=400
    kern_params=[(kern_one, 1, 3, 3),(kern_two, kern_one, 3, 3),(kern_third, kern_two, 3, 3),
                 (kern_third * 6 * 6, n_hidden),(n_hidden, 7)]
    params={'learning_rate': learning_rate,
            'kern_params':kern_params}
    return params

if __name__ == '__main__':
    dataset_path="/home/user/cf/conv_frames/cls/images/"
    dataset=load.get_images(dataset_path)
    out_path="/home/user/cf/exp1/conv_net"
    cls=learning.create_classifer(dataset_path,out_path,built_conv_cls,flat=False)
    learning.evaluate_cls(dataset_path,out_path,flat=False)
示例#3
0
def evaluate_cls(dataset_path,cls_path,flat=True):
    dataset=load.get_images(dataset_path)
    cls=utils.read_object(cls_path) #learning_iter(dataset,cls)
    correct=check_prediction(dataset,cls,flat)
    print(correct)