Skip to content

Commit

Permalink
architecture updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Scitator committed May 23, 2020
1 parent c16df44 commit 249b671
Show file tree
Hide file tree
Showing 68 changed files with 183 additions and 75 deletions.
38 changes: 38 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,24 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).

### Added

-

### Changed

-

### Removed

-

### Fixed

-


## [20.05.1] - 2020-05-23

### Added

- Circle loss implementation ([#802](https://github.com/catalyst-team/catalyst/pull/802))
- BatchBalanceSampler for metric learning and classification ([#806](https://github.com/catalyst-team/catalyst/pull/806))
Expand All @@ -31,6 +49,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- device selection fix for [#798](https://github.com/catalyst-team/catalyst/issues/798) ([#815](https://github.com/catalyst-team/catalyst/pull/815))
- batch size counting fix for [#799](https://github.com/catalyst-team/catalyst/issues/799) and [#755](https://github.com/catalyst-team/catalyst/issues/755) issues ([#809](https://github.com/catalyst-team/catalyst/pull/809))


## [20.05] - 2020-05-07

### Added
Expand Down Expand Up @@ -91,3 +110,22 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
### Fixed

-


## [YY.MM.R] - YYYY-MM-DD

### Added

-

### Changed

-

### Removed

-

### Fixed

-
34 changes: 25 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ import torch
from torch.nn import functional as F
from torch.utils.data import DataLoader
from catalyst import dl
from catalyst.contrib.data.dataset import MNIST, ToTensor
from catalyst.contrib.data.transforms import ToTensor
from catalyst.contrib.datasets import MNIST
from catalyst.utils import metrics

model = torch.nn.Linear(28 * 28, 10)
Expand Down Expand Up @@ -212,7 +213,8 @@ import torch
from torch.nn import functional as F
from torch.utils.data import DataLoader
from catalyst import dl
from catalyst.contrib.data.dataset import MNIST, ToTensor
from catalyst.contrib.data.transforms import ToTensor
from catalyst.contrib.datasets import MNIST
from catalyst.utils import metrics

model = torch.nn.Linear(28 * 28, 10)
Expand Down Expand Up @@ -265,7 +267,8 @@ from torch import nn
from torch.nn import functional as F
from torch.utils.data import DataLoader
from catalyst import dl
from catalyst.contrib.data.dataset import MNIST, ToTensor
from catalyst.contrib.data.transforms import ToTensor
from catalyst.contrib.datasets import MNIST
from catalyst.utils import metrics

class ClassifyAE(nn.Module):
Expand Down Expand Up @@ -338,7 +341,8 @@ from torch import nn
from torch.nn import functional as F
from torch.utils.data import DataLoader
from catalyst import dl
from catalyst.contrib.data.dataset import MNIST, ToTensor
from catalyst.contrib.data.transforms import ToTensor
from catalyst.contrib.datasets import MNIST
from catalyst.utils import metrics

LOG_SCALE_MAX = 2
Expand Down Expand Up @@ -436,7 +440,8 @@ from torch import nn
from torch.nn import functional as F
from torch.utils.data import DataLoader
from catalyst import dl
from catalyst.contrib.data.dataset import MNIST, ToTensor
from catalyst.contrib.data.transforms import ToTensor
from catalyst.contrib.datasets import MNIST
from catalyst.utils import metrics

class ClassifyUnet(nn.Module):
Expand Down Expand Up @@ -511,7 +516,8 @@ from torch import nn
from torch.nn import functional as F
from torch.utils.data import DataLoader
from catalyst import dl
from catalyst.contrib.data.dataset import MNIST, ToTensor
from catalyst.contrib.data.transforms import ToTensor
from catalyst.contrib.datasets import MNIST
from catalyst.contrib.nn.modules import Flatten, GlobalMaxPool2d, Lambda

latent_dim = 128
Expand Down Expand Up @@ -668,7 +674,8 @@ import torch
from torch import nn
from torch.nn import functional as F
from catalyst import dl, utils
from catalyst.contrib.data.dataset import MNIST, ToTensor
from catalyst.contrib.data.transforms import ToTensor
from catalyst.contrib.datasets import MNIST
from catalyst.utils import metrics

class ClassifyAE(nn.Module):
Expand Down Expand Up @@ -749,15 +756,24 @@ utils.distributed_cmd_run(train)


### Structure
- **contrib** - additional modules contributed by Catalyst users.
- **core** - framework core with main abstractions -
Experiment, Runner, Callback and State.
- **data** - useful tools and scripts for data processing.
- **dl** – runner for training and inference,
all of the classic ML and CV/NLP/RecSys metrics
and a variety of callbacks for training, validation
and inference of neural networks.
- **utils** - typical utils for Deep Learning research.
- **tools** - extra tools for Deep Learning research, class-based helpers.
- **utils** - typical utils for Deep Learning research, function-based helpers.
- **contrib** - additional modules contributed by Catalyst users.
- contrib/data - extra data-tools for CV, NLP and RecSys.
- contrib/datasets - typical datasets, such as MNIST, etc.
- contrib/dl - extensions for `catalyst.dl`
- contrib/models - predefined models for CV, NLP and RecSys.
- contrib/nn - extra PyTorch modules.
- contrib/scripts - user scripts for common deep learning routine.
- contrib/tools - `catalyst.tools` extensions.
- contrib/utils - `catalyst.utils` extensions.


### Tests
Expand Down
2 changes: 1 addition & 1 deletion catalyst/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "20.05"
__version__ = "20.05.1"
3 changes: 3 additions & 0 deletions catalyst/contrib/data/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# flake8: noqa

from .transforms import Compose, Normalize, normalize, to_tensor, ToTensor
8 changes: 0 additions & 8 deletions catalyst/contrib/data/dataset/__init__.py

This file was deleted.

3 changes: 1 addition & 2 deletions catalyst/contrib/data/nlp/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
# flake8: noqa
from .classification import *
from .language_modeling import *
from .dataset import *
2 changes: 0 additions & 2 deletions catalyst/contrib/data/nlp/classification/__init__.py

This file was deleted.

8 changes: 8 additions & 0 deletions catalyst/contrib/data/nlp/dataset/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# flake8: noqa

from catalyst.contrib.data.nlp.dataset.language_modeling import (
LanguageModelingDataset,
)
from catalyst.contrib.data.nlp.dataset.text_classification import (
TextClassificationDataset,
)
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import torch # noqa: F401
from transformers import AutoTokenizer

from catalyst.contrib.data.nlp.language_modeling import LanguageModelingDataset
from catalyst.contrib.data.nlp.dataset import LanguageModelingDataset

texts = [
"""Bonaparte Crossing the Alps is an oil-on-canvas painting by French artist""", # noqa: E501
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from catalyst.contrib.data.nlp.classification import TextClassificationDataset
from catalyst.contrib.data.nlp.dataset import TextClassificationDataset

texts = [
"The color of this T-shirt is sooo so horrible",
Expand Down
2 changes: 0 additions & 2 deletions catalyst/contrib/data/nlp/language_modeling/__init__.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
"""
This subpackage was borrowed from
torchvision(https://github.com/pytorch/vision).
"""

import numpy as np

import torch
Expand Down Expand Up @@ -149,3 +154,6 @@ def __repr__(self):
return self.__class__.__name__ + "(mean={0}, std={1})".format(
self.mean, self.std
)


__all__ = ["Compose", "Normalize", "ToTensor", "normalize", "to_tensor"]
File renamed without changes.
3 changes: 3 additions & 0 deletions catalyst/contrib/datasets/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# flake8: noqa

from catalyst.contrib.datasets.mnist import MNIST
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import torch
from torch.utils.data import Dataset

from catalyst.contrib.data.dataset.utils import download_and_extract_archive
from catalyst.contrib.datasets.utils import download_and_extract_archive


class MNIST(Dataset):
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
from torch.utils.data import DataLoader

from catalyst.contrib import registry
from catalyst.contrib.data.dataset import MNIST, ToTensor
from catalyst.contrib.data.transforms import ToTensor
from catalyst.contrib.datasets import MNIST
from catalyst.contrib.dl.callbacks.optimizer import SaveModelGradsCallback
from catalyst.core import (
Callback,
Expand Down
3 changes: 2 additions & 1 deletion catalyst/contrib/dl/callbacks/tests/test_trace_callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
from torch.utils.data import DataLoader

from catalyst.contrib import registry
from catalyst.contrib.data.dataset import MNIST, ToTensor
from catalyst.contrib.data.transforms import ToTensor
from catalyst.contrib.datasets import MNIST
from catalyst.contrib.dl.callbacks.trace import TracerCallback
from catalyst.core import (
Callback,
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import numpy as np
import pytest

from catalyst.contrib.utils.tools.tensorboard import (
from catalyst.contrib.tools.tensorboard import (
EventReadingException,
EventsFileReader,
SummaryReader,
Expand Down
2 changes: 1 addition & 1 deletion catalyst/contrib/utils/cv/tests/test_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import torch

from catalyst import utils
from catalyst.contrib.data.dataset.transforms import normalize, to_tensor
from catalyst.contrib.data.transforms import normalize, to_tensor
from catalyst.contrib.utils.cv.tensor import _IMAGENET_MEAN, _IMAGENET_STD


Expand Down
2 changes: 1 addition & 1 deletion catalyst/contrib/utils/plotly.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import plotly.graph_objs as go
from plotly.offline import init_notebook_mode, iplot

from .tools.tensorboard import SummaryItem, SummaryReader
from catalyst.contrib.tools.tensorboard import SummaryItem, SummaryReader


def _get_tensorboard_scalars(
Expand Down
2 changes: 1 addition & 1 deletion catalyst/core/callbacks/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from tqdm import tqdm

from catalyst.contrib.utils.tools.tensorboard import SummaryWriter
from catalyst.contrib.tools.tensorboard import SummaryWriter
from catalyst.core import Callback, CallbackNode, CallbackOrder, State, utils

from . import formatters
Expand Down
2 changes: 1 addition & 1 deletion catalyst/core/callbacks/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import torch

from catalyst.core import Callback, CallbackNode, CallbackOrder, State, utils
from catalyst.utils import meters
from catalyst.tools import meters

logger = logging.getLogger(__name__)

Expand Down
15 changes: 15 additions & 0 deletions catalyst/core/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,21 @@ def need_backward_pass(self):
)
return self.is_train_loader

@property
def loader_step(self):
"""Alias for `state.loader_batch_step`.
.. warning::
Deprecated, saved for backward compatibility.
Please use `state.loader_batch_step` instead.
"""
warnings.warn(
"`loader_step` was deprecated, "
"please use `loader_batch_step` instead",
DeprecationWarning,
)
return self.loader_batch_step

def get_attr(self, key: str, inner_key: str = None) -> Any:
"""
Alias for python `getattr` method. Useful for Callbacks preparation
Expand Down
28 changes: 22 additions & 6 deletions catalyst/data/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,25 @@ def __call__(self, element):
return result


__all__ = [
"ReaderSpec",
"ScalarReader",
"LambdaReader",
"ReaderCompose",
]
try:
# @TODO: remove hotfix
from catalyst.contrib.data.cv.reader import ( # noqa: F401
ImageReader,
MaskReader,
)

__all__ = [
"ReaderSpec",
"ScalarReader",
"LambdaReader",
"ReaderCompose",
"ImageReader",
"MaskReader",
]
except ImportError:
__all__ = [
"ReaderSpec",
"ScalarReader",
"LambdaReader",
"ReaderCompose",
]
2 changes: 1 addition & 1 deletion catalyst/data/scripts/project_embeddings.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import torch

from catalyst.contrib.utils.tools.tensorboard import SummaryWriter
from catalyst.contrib.tools.tensorboard import SummaryWriter


def build_args(parser):
Expand Down
2 changes: 1 addition & 1 deletion catalyst/dl/callbacks/confusion_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import torch.distributed

from catalyst.dl import Callback, CallbackNode, CallbackOrder, State, utils
from catalyst.utils import meters
from catalyst.tools import meters


class ConfusionMatrixCallback(Callback):
Expand Down
2 changes: 1 addition & 1 deletion catalyst/dl/callbacks/metrics/auc.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import List

from catalyst.dl.callbacks import MeterMetricsCallback
from catalyst.utils import meters
from catalyst.tools import meters


class AUCCallback(MeterMetricsCallback):
Expand Down
2 changes: 1 addition & 1 deletion catalyst/dl/callbacks/metrics/ppv_tpr_f1.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import List

from catalyst.dl.callbacks import MeterMetricsCallback
from catalyst.utils import meters
from catalyst.tools import meters


class PrecisionRecallF1ScoreCallback(MeterMetricsCallback):
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
class mAPMeter(meter.Meter):
"""
This meter is a wrapper for
:py:class:`catalyst.utils.meters.apmeter.APMeter`.
:py:class:`catalyst.tools.meters.apmeter.APMeter`.
The mAPMeter is designed to operate on `NxK` Tensors `output` and
`target`, and optionally a `Nx1` Tensor weight where:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 249b671

Please sign in to comment.