Skip to content

Commit

Permalink
[ENH] Some polish
Browse files Browse the repository at this point in the history
  • Loading branch information
xuyxu committed Nov 11, 2020
1 parent 474d50f commit 0e2a554
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 17 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
*.pyc
*.swp

.idea
build
dist/
torchensemble.egg-info
4 changes: 4 additions & 0 deletions MINIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include MANIFEST.in

# exclude from sdist
exclude examples
2 changes: 2 additions & 0 deletions examples/DATASET.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* The YearPredictionMSD dataset can be downloaded from "https://www.csie.ntu.edu.tw/~cjlin/libsvmtools/datasets/regression.html#YearPredictionMSD"
* Please modify the `data_dir` in classification_cifar10_cnn.py, or `train_path` and `test_path` in regression_YearPredictionMSD_mlp.py for personal use
27 changes: 14 additions & 13 deletions examples/classification_cifar10_cnn.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def num_flat_features(self, X):
transforms.ToTensor(),
transforms.Normalize((0.4914, 0.4822, 0.4465),
(0.2023, 0.1994, 0.2010))])

train_loader = DataLoader(datasets.CIFAR10(
data_dir, train=True, download=True, transform=transformer),
batch_size=batch_size, shuffle=True)
Expand All @@ -94,11 +94,11 @@ def num_flat_features(self, X):

# FusionClassifier
model = FusionClassifier(estimator=LeNet5,
n_estimators=n_estimators,
output_dim=output_dim,
lr=lr,
weight_decay=weight_decay,
epochs=epochs)
n_estimators=n_estimators,
output_dim=output_dim,
lr=lr,
weight_decay=weight_decay,
epochs=epochs)

tic = time.time()
model.fit(train_loader)
Expand All @@ -117,12 +117,12 @@ def num_flat_features(self, X):

# VotingClassifier
model = VotingClassifier(estimator=LeNet5,
n_estimators=n_estimators,
output_dim=output_dim,
lr=lr,
weight_decay=weight_decay,
epochs=epochs,
n_jobs=1)
n_estimators=n_estimators,
output_dim=output_dim,
lr=lr,
weight_decay=weight_decay,
epochs=epochs,
n_jobs=1)

tic = time.time()
model.fit(train_loader)
Expand Down Expand Up @@ -169,7 +169,8 @@ def num_flat_features(self, X):
output_dim=output_dim,
lr=lr,
weight_decay=weight_decay,
epochs=epochs)
epochs=epochs,
shrinkage_rate=1.)

tic = time.time()
model.fit(train_loader)
Expand Down
4 changes: 3 additions & 1 deletion examples/regression_YearPredictionMSD_mlp.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def load_data(batch_size):
train = load_svmlight_file(train_path)
test = load_svmlight_file(test_path)

# Numpy array -> Tensor
X_train, X_test = (torch.FloatTensor(train[0].toarray()),
torch.FloatTensor(test[0].toarray()))

Expand Down Expand Up @@ -173,7 +174,8 @@ def forward(self, X):
output_dim=output_dim,
lr=lr,
weight_decay=weight_decay,
epochs=epochs)
epochs=epochs,
shrinkage_rate=1.)

tic = time.time()
model.fit(train_loader)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def run(self):

setup(
name='torchensemble',
version='0.0.1',
version='1.0.0',
author='AaronX121',

description=('Implementations of scikit-learn like ensemble methods in'
Expand Down
4 changes: 2 additions & 2 deletions torchensemble/bagging.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ def _parallel_fit(epoch, estimator_idx,

msg = ('Estimator: {:03d} | Epoch: {:03d} |'
' Batch: {:03d} | Loss: {:.5f} | Correct:'
' {:d}/{:d}')
' {:03d}/{:03d}')
print(msg.format(estimator_idx, epoch, batch_idx, loss,
correct, batch_size))
correct, sampling_X_train.size()[0]))
else:
msg = ('Estimator: {:03d} | Epoch: {:03d} |'
' Batch: {:03d} | Loss: {:.5f}')
Expand Down

0 comments on commit 0e2a554

Please sign in to comment.