Exemplo n.º 1
0
import time
"""Stand alone mode"""
ray.init()
"""Cluster mode"""
# ray.init(redis_address="192.168.x.x:6379")

(x_train, y_train, x_test, y_test) = uci_adult.load_data()

start_time = time.time()

est_configs = [
    ExtraRandomForestConfig(n_jobs=-1),
    ExtraRandomForestConfig(n_jobs=-1),
    ExtraRandomForestConfig(n_jobs=-1),
    ExtraRandomForestConfig(n_jobs=-1),
    RandomForestConfig(n_jobs=-1),
    RandomForestConfig(n_jobs=-1),
    RandomForestConfig(n_jobs=-1),
    RandomForestConfig(n_jobs=-1)
]

auto_cascade = AutoGrowingCascadeLayer(est_configs=est_configs,
                                       early_stopping_rounds=4,
                                       n_classes=2,
                                       distribute=True,
                                       seed=0)

model = Graph()
model.add(auto_cascade)
model.summary()
model.fit_transform(x_train, y_train, x_test, y_test)
Exemplo n.º 2
0
# set_dataset_dir(osp.join(osp.expanduser('~'), 'forestlayer', 'data'))

(x_train, y_train, x_train_plus), (x_test, y_test, x_test_plus) = smallnorb.load_data(osp.join(get_dataset_dir(), "NORB"))

x_train = x_train[:100]
y_train = y_train[:100]
x_train_plus = x_train_plus[:100]
x_test = x_test[:50]
y_test = y_test[:50]
x_test_plus = x_test_plus[:50]

print('train shape and plus shape', x_train.shape, x_train_plus.shape)
print('test shape and plus shape', x_test.shape, x_test_plus.shape)

rf1 = ExtraRandomForestConfig(n_folds=3, n_jobs=-1, min_samples_leaf=10, max_features='auto')
rf2 = RandomForestConfig(n_folds=3, n_jobs=-1, min_samples_leaf=10)

windows = [Window(win_x=24, win_y=24, stride_x=2, stride_y=2, pad_x=0, pad_y=0),
           Window(34, 34, 2, 2),
           Window(48, 48, 2, 2)]

est_for_windows = [[rf1, rf2],
                   [rf1, rf2],
                   [rf1, rf2]]

data_save_dir = osp.join(get_data_save_base(), 'small_norb')
model_save_dir = osp.join(get_model_save_base(), 'small_norb')

mgs = MultiGrainScanLayer(windows=windows,
                          est_for_windows=est_for_windows,
                          n_class=10,
Exemplo n.º 3
0
fl.init()

(x_train, y_train, x_test, y_test) = uci_adult.load_data()

start_time = time.time()

print(x_train.shape[0], 'train samples')
print(x_test.shape[0], 'test samples')
print(x_train.shape[1], 'features')

est_configs = [
    ExtraRandomForestConfig(),
    ExtraRandomForestConfig(),
    ExtraRandomForestConfig(),
    ExtraRandomForestConfig(),
    RandomForestConfig(),
    RandomForestConfig(),
    RandomForestConfig(),
    RandomForestConfig(),
]

agc = AutoGrowingCascadeLayer(est_configs=est_configs,
                              early_stopping_rounds=4,
                              max_layers=0,
                              stop_by_test=True,
                              n_classes=2,
                              data_save_rounds=0,
                              data_save_dir=osp.join(get_data_save_base(),
                                                     'uci_adult',
                                                     'auto_cascade'),
                              keep_in_mem=False,
Exemplo n.º 4
0
x_train = x_train.reshape(60000, -1, 28, 28)
x_test = x_test.reshape(10000, -1, 28, 28)

# small data for example.
x_train = x_train[:600, :, :, :]
x_test = x_test[:300, :, :, :]
y_train = y_train[:600]
y_test = y_test[:300]

print(x_train.shape, 'train', x_train.dtype, getmbof(x_train))
print(x_test.shape, 'test', x_test.dtype, getmbof(x_test))

rf1 = ExtraRandomForestConfig(n_jobs=-1,
                              min_samples_leaf=10,
                              max_features="auto")
rf2 = RandomForestConfig(n_jobs=-1, min_samples_leaf=10)

windows = [
    Window(win_x=7, win_y=7, stride_x=2, stride_y=2, pad_x=0, pad_y=0),
    Window(10, 10, 2, 2),
    Window(13, 13, 2, 2)
]

est_for_windows = [[rf1, rf2], [rf1, rf2], [rf1, rf2]]

mgs = MultiGrainScanLayer(windows=windows,
                          est_for_windows=est_for_windows,
                          n_class=10,
                          distribute=True,
                          dis_level=2,
                          keep_in_mem=False)