Ejemplo n.º 1
0
def prepare_model(opt):
    if opt.dataset == 'mnist':
        feat_layer = ndf.MNISTFeatureLayer(opt.feat_dropout)
    elif opt.dataset == 'adult':
        feat_layer = ndf.UCIAdultFeatureLayer(opt.feat_dropout)
    elif opt.dataset == 'letter':
        feat_layer = ndf.UCILetterFeatureLayer(opt.feat_dropout)
    elif opt.dataset == 'yeast':
        feat_layer = ndf.UCIYeastFeatureLayer(opt.feat_dropout)
    else:
        raise NotImplementedError

    forest = ndf.Forest(n_tree=opt.n_tree,
                        tree_depth=opt.tree_depth,
                        n_in_feature=feat_layer.get_out_feature_size(),
                        tree_feature_rate=opt.tree_feature_rate,
                        n_class=opt.n_class,
                        jointly_training=opt.jointly_training)
    model = ndf.NeuralDecisionForest(feat_layer, forest)

    if opt.cuda:
        model = model.cuda()
    else:
        model = model.cpu()

    return model
Ejemplo n.º 2
0
def prepare_model(opt):
    if opt.dataset == 'mnist':
        feat_layer = ndf.MNISTFeatureLayer(opt.feat_dropout)
    elif opt.dataset == 'adult':
        feat_layer = ndf.UCIAdultFeatureLayer(opt.feat_dropout)
    elif opt.dataset == 'letter':
        feat_layer = ndf.UCILetterFeatureLayer(opt.feat_dropout)
    elif opt.dataset == 'yeast':
        feat_layer = ndf.UCIYeastFeatureLayer(opt.feat_dropout)
    elif opt.dataset == 'gisette':
        feat_layer = ndf.UCIGisetteFeatureLayer(opt.feat_dropout)
    elif opt.dataset == 'arrhythmia':
        feat_layer = ndf.UCIArrhythmiaFeatureLayer(opt.feat_dropout)
    elif opt.dataset == 'cardiotocography':
        feat_layer = ndf.UCICardiotocographyFeatureLayer(opt.feat_dropout)
    elif opt.dataset == 'breastcancer':
        feat_layer = ndf.UCIBreastcancerFeatureLayer(opt.feat_dropout)
    elif opt.dataset == 'nomao':
        feat_layer = ndf.UCINomaoFeatureLayer(opt.feat_dropout)
    elif opt.dataset == 'mutiplefeatures':
        feat_layer = ndf.UCIMutiplefeaturesFeatureLayer(opt.feat_dropout)
    elif opt.dataset == 'madelon':
        feat_layer = ndf.UCIMadelonFeatureLayer(opt.feat_dropout)
    elif opt.dataset == 'secom':
        feat_layer = ndf.UCISecomFeatureLayer(opt.feat_dropout)
    elif opt.dataset == 'isolet5':
        feat_layer = ndf.UCIIsolet5FeatureLayer(opt.feat_dropout)
    
    else:
        raise NotImplementedError

    forest = ndf.Forest(n_tree=opt.n_tree, tree_depth=opt.tree_depth, n_in_feature=feat_layer.get_out_feature_size(),
                        tree_feature_rate=opt.tree_feature_rate, n_class=opt.n_class,
                        jointly_training=opt.jointly_training)
    model = ndf.NeuralDecisionForest(feat_layer, forest)

    if opt.cuda:
        model = model.cuda()
    else:
        model = model.cpu()

    return model