Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
164 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
from unittest.mock import patch | ||
|
||
import pytest | ||
|
||
from autokeras.image.image_supervised import * | ||
from tests.common import clean_dir, MockProcess, simple_transform, mock_train, TEST_TEMP_DIR | ||
|
||
|
||
@patch('torch.multiprocessing.get_context', side_effect=MockProcess) | ||
@patch('autokeras.search.ModelTrainer.train_model', side_effect=mock_train) | ||
def test_fit_predict(_, _1): | ||
Constant.MAX_ITER_NUM = 1 | ||
Constant.MAX_MODEL_NUM = 4 | ||
Constant.SEARCH_MAX_ITER = 1 | ||
Constant.T_MIN = 0.8 | ||
Constant.DATA_AUGMENTATION = False | ||
|
||
clf = ImageClassifier(path=TEST_TEMP_DIR, verbose=True) | ||
train_x = np.random.rand(100, 25, 25, 1) | ||
train_y = np.random.randint(0, 5, 100) | ||
clf.fit(train_x, train_y) | ||
results = clf.predict(train_x) | ||
assert all(map(lambda result: result in train_y, results)) | ||
|
||
clf = ImageClassifier1D(path=TEST_TEMP_DIR, verbose=True) | ||
train_x = np.random.rand(100, 25, 1) | ||
train_y = np.random.randint(0, 5, 100) | ||
clf.fit(train_x, train_y) | ||
results = clf.predict(train_x) | ||
assert all(map(lambda result: result in train_y, results)) | ||
|
||
clf = ImageClassifier3D(path=TEST_TEMP_DIR, verbose=True) | ||
train_x = np.random.rand(100, 25, 25, 25, 1) | ||
train_y = np.random.randint(0, 5, 100) | ||
clf.fit(train_x, train_y) | ||
results = clf.predict(train_x) | ||
assert all(map(lambda result: result in train_y, results)) | ||
|
||
clf = ImageRegressor1D(path=TEST_TEMP_DIR, verbose=True) | ||
train_x = np.random.rand(100, 25, 1) | ||
train_y = np.random.randint(0, 5, 100) | ||
clf.fit(train_x, train_y) | ||
results = clf.predict(train_x) | ||
assert len(results) == len(train_y) | ||
|
||
clf = ImageRegressor3D(path=TEST_TEMP_DIR, verbose=True) | ||
train_x = np.random.rand(100, 25, 25, 25, 1) | ||
train_y = np.random.randint(0, 5, 100) | ||
clf.fit(train_x, train_y) | ||
results = clf.predict(train_x) | ||
assert len(results) == len(train_y) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters