tfutils.tests package¶
Submodules¶
tfutils.tests.test_base module¶
Test base module.
-
class
tfutils.tests.test_base.
TestBase
(methodName='runTest')[source]¶ Bases:
unittest.case.TestCase
-
static
custom_train_loop
(sess, train_targets, **loop_params)[source]¶ Define Custom training loop.
Parameters: - sess (tf.Session) – Current tensorflow session.
- train_targets (list) – Description.
- **loop_params – Optional kwargs needed to perform custom train loop.
Returns: A dictionary containing train targets evaluated by the session.
Return type: dict
-
database_name
= '_tfutils'¶
-
static
get_extraction_target
(inputs, outputs, to_extract, **loss_params)[source]¶ Produce validation target function.
Example validation target function to use to provide targets for extracting features. This function also adds a standard “loss” target which you may or not may not want
- The to_extract argument must be a dictionary of the form
- {name_for_saving: name_of_actual_tensor, …}
where the “name_for_saving” is a human-friendly name you want to save extracted features under, and name_of_actual_tensor is a name of the tensor in the tensorflow graph outputing the features desired to be extracted. To figure out what the names of the tensors you want to extract are “to_extract” argument, uncomment the commented-out lines, which will print a list of all available tensor names.
-
static
get_first_image_target
(inputs, outputs, **ttarg_params)[source]¶ Return target for saving the first image of every batch.
Used in test_training_save test to test save_to_gfs option.
-
host
= 'localhost'¶
-
port
= 29101¶
-
test_custom_training
()[source]¶ Illustrate training with custom training loop.
This test illustrates how basic training is performed with a custom training loop using the tfutils.base.train_from_params function.
-
test_feature_extraction
()[source]¶ Illustrate feature extraction.
This is a test illustrating how to perform feature extraction using tfutils.base.test_from_params. The basic idea is to specify a validation target that is simply the actual output of the model at some layer. (See the “get_extraction_target” function above as well.) This test assumes that test_train has run first.
After the test is run, the results of the feature extraction are saved in the Grid File System associated with the mongo database, with one file per batch of feature results. See how the features are accessed by reading the test code below.
-
test_training
()[source]¶ Illustrate training.
This test illustrates how basic training is performed using the tfutils.base.train_from_params function. This is the first in a sequence of interconnected tests. It creates a pretrained model that is used by the next few tests (test_validation and test_feature_extraction).
As can be seen by looking at how the test checks for correctness, after the training is run, results of training, including (intermittently) the full variables needed to re-initialize the tensorflow model, are stored in a MongoDB.
Also see docstring of the tfutils.base.train_from_params function for more detailed information about usage.
-
test_validation
()[source]¶ Illustrate validation.
This is a test illustrating how to compute performance on a trained model on a new dataset, using the tfutils.base.test_from_params function. This test assumes that test_training function has run first (to provide a pre-trained model to validate).
After the test is run, results from the validation are stored in the MongoDB. (The test shows how the record can be loaded for inspection.)
See the docstring of tfutils.base.test_from_params for more detailed information on usage.
-
static
-
class
tfutils.tests.test_base.
TestMultiModel
(methodName='runTest')[source]¶ Bases:
tfutils.tests.test_base.TestBase
-
test_training
()[source]¶ Illustrate training.
This test illustrates how basic training is performed using the tfutils.base.train_from_params function. This is the first in a sequence of interconnected tests. It creates a pretrained model that is used by the next few tests (test_validation and test_feature_extraction).
As can be seen by looking at how the test checks for correctness, after the training is run, results of training, including (intermittently) the full variables needed to re-initialize the tensorflow model, are stored in a MongoDB.
Also see docstring of the tfutils.base.train_from_params function for more detailed information about usage.
-
test_validation
()[source]¶ Illustrate validation.
This is a test illustrating how to compute performance on a trained model on a new dataset, using the tfutils.base.test_from_params function. This test assumes that test_training function has run first (to provide a pre-trained model to validate).
After the test is run, results from the validation are stored in the MongoDB. (The test shows how the record can be loaded for inspection.)
See the docstring of tfutils.base.test_from_params for more detailed information on usage.
-
tfutils.tests.test_dbinterface module¶
Test DBInterface.
-
class
tfutils.tests.test_dbinterface.
TestDBInterface
(methodName='runTest')[source]¶ Bases:
unittest.case.TestCase
-
CACHE_DIR
= 'TFUTILS_TEST_CACHE_DIR'¶
-
COLLECTION_NAME
= 'TFUTILS_TESTCOL'¶
-
DATABASE_NAME
= 'TFUTILS_TESTDB'¶
-
EXP_ID
= 'TEST_EXP_ID'¶
-
HOST
= 'localhost'¶
-
PORT
= 29101¶
-