コード例 #1
0
 def test_disk(self):
     metric = DiskUsage()
     self.assertEqual(metric.result(), 0)
     metric.update()
     self.assertGreaterEqual(metric.result(), 0)
     metric.reset()
     self.assertEqual(metric.result(), 0)
コード例 #2
0
from __future__ import print_function
from __future__ import division
from __future__ import absolute_import

import torch
from avalanche.evaluation.metrics import ACC, CF, RAMU, DiskUsage, CM, \
        TimeUsage, GPUUsage, CPUUsage


if __name__ == '__main__':

    metrics = {
        'acc': ACC(),
        'cf': CF(),
        'ramu': RAMU(),
        'disk': DiskUsage(),
        'disk_io': DiskUsage(disk_io=True),
        'cm': CM(),
        'time': TimeUsage(),
        'gpu': GPUUsage(gpu_id=0),
        'cpu': CPUUsage()
    }

    n_tasks = 3

    for t in range(n_tasks):

        tensors = ( 
            torch.randint(low=0, high=10, size=(20, 1)),
            torch.randint(low=0, high=10, size=(20, 1))
        )
コード例 #3
0
    def test_standalone_disk_usage_multi_dir(self):
        with tempfile.TemporaryDirectory() as tmp_dirA:
            with tempfile.TemporaryDirectory() as tmp_dirB:
                uut = DiskUsage([tmp_dirA, tmp_dirB])

                uut.update()
                base_value = uut.result()
                with open(str(Path(tmp_dirA) / 'blob_fileA.bin'), "wb") as f:
                    f.write(os.urandom(512))

                uut.update()
                self.assertLessEqual(base_value, uut.result())

                base_value = uut.result()

                with open(str(Path(tmp_dirB) / 'blob_fileB.bin'), "wb") as f:
                    f.write(os.urandom(512))

                uut.update()
                self.assertLessEqual(base_value, uut.result())
コード例 #4
0
ファイル: metrics_test.py プロジェクト: tyler-hayes/avalanche
# Python 2-3 compatible
from __future__ import print_function
from __future__ import division
from __future__ import absolute_import

import torch
from avalanche.evaluation.metrics import ACC, CF, RAMU, DiskUsage, CM, \
        TimeUsage, GPUUsage, CPUUsage

if __name__ == '__main__':

    metrics = {
        'acc': ACC(),
        'cf': CF(),
        'ramu': RAMU(),
        'disk': DiskUsage(),
        'cm': CM(),
        'time': TimeUsage(),
        'gpu': GPUUsage(gpu_id=0),
        'cpu': CPUUsage()
    }

    n_tasks = 3

    for t in range(n_tasks):

        tensors = (torch.randint(low=0, high=10, size=(20, 1)),
                   torch.randint(low=0, high=10, size=(20, 1)))

        tensors_list = ([
            torch.randint(low=0, high=10, size=(20, 1)) for _ in range(3)
コード例 #5
0
    def test_standalone_disk_usage(self):
        with tempfile.TemporaryDirectory() as tmp_dir:
            uut = DiskUsage(tmp_dir)

            # Assert result is None when created
            self.assertEqual(0, uut.result())

            # Base usage
            uut.update()
            self.assertLessEqual(0, uut.result())

            # Assert reset actually resets
            uut.reset()
            self.assertEqual(0, uut.result())

            uut.update()
            base_value = uut.result()
            with open(str(Path(tmp_dir) / 'blob_file.bin'), "wb") as f:
                f.write(os.urandom(512))

            # Shouldn't change between calls to update
            self.assertEqual(base_value, uut.result())

            uut.update()

            self.assertLessEqual(base_value, uut.result())