setup: switch to Python 3.8+

Co-authored-by: Hervé BREDIN <hbredin@users.noreply.github.com>
This commit is contained in:
Harry Coultas BlumandHervé BREDIN authored and GitHub committed 2020-11-02 21:12:58 +01:00
1 parent 40e11bb896
commit 61572080b2
6 files changed
+18 -28

No files matched your search

+1 -1
View File
@@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7, 3.8]
python-version: [3.8]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
+4 -7
View File
@@ -20,8 +20,8 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
# from functools import cached_property
import warnings
from functools import cached_property
from typing import Dict, List, Optional, Text, Tuple, Union
import numpy as np
@@ -119,18 +119,15 @@ class Inference:
self.batch_size = batch_size
# @cached_property
@property
@cached_property
def is_multi_task(self) -> bool:
return self.model.is_multi_task
# @cached_property
@property
@cached_property
def task_specifications(self) -> List[Tuple[TaskName, TaskSpecification]]:
return list(self.model.hparams.task_specifications.items())
# @cached_property
@property
@cached_property
def model_introspection(self) -> List[Tuple[TaskName, ModelIntrospection]]:
return list(self.model.hparams.model_introspection.items())
+3 -5
View File
@@ -22,8 +22,7 @@
import warnings
from dataclasses import dataclass
# from functools import cached_property
from functools import cached_property
from importlib import import_module
from typing import Any, Dict, List, Optional, Text, Tuple, Union
@@ -126,8 +125,7 @@ class Model(pl.LightningModule):
self.task = task
self.task.audio = self.audio
# @cached_property
@property
@cached_property
def is_multi_task(self) -> bool:
if hasattr(self, "task"):
return self.task.is_multi_task
@@ -157,7 +155,7 @@ class Model(pl.LightningModule):
Model introspection.
"""
example_input_array = self.task.example_input_array()
example_input_array = self.task.example_input_array
batch_size, num_samples, num_channels = example_input_array.shape
example_input_array = torch.randn(
(1, num_samples, num_channels),
+9 -10
View File
@@ -21,10 +21,11 @@
# SOFTWARE.
from __future__ import annotations
from dataclasses import dataclass
from enum import Enum
# from functools import cached_property
from functools import cached_property
from typing import TYPE_CHECKING, List, Optional, Text, Tuple, Union
import numpy as np
@@ -163,8 +164,7 @@ class Task(pl.LightningDataModule):
"""
pass
# @cached_property
@property
@cached_property
def is_multi_task(self) -> bool:
""""Check whether multiple tasks are addressed at once"""
return len(self.specifications) > 1
@@ -271,12 +271,11 @@ class Task(pl.LightningDataModule):
drop_last=True,
)
# @cached_property
@property
@cached_property
def example_input_duration(self) -> float:
return 2.0 if self.duration is None else self.duration
#  TODO: make it a cached_property
@cached_property
def example_input_array(self):
# this method is called in Model.introspect where it is used
# to automagically infer the temporal resolution of the
@@ -318,7 +317,7 @@ class Task(pl.LightningDataModule):
# default training_step provided for convenience
# can obviously be overriden for each task
def training_step(self, model: "Model", batch, batch_idx: int):
def training_step(self, model: Model, batch, batch_idx: int):
"""Guess default training_step according to task specification
* NLLLoss for regular classification
@@ -327,7 +326,7 @@ class Task(pl.LightningDataModule):
In case of multi-tasking, it will default to summing loss of each task.
Parameters
----------
----------
model : Model
Model currently being trained.
batch : (usually) dict of torch.Tensor
@@ -362,7 +361,7 @@ class Task(pl.LightningDataModule):
# default configure_optimizers provided for convenience
# can obviously be overriden for each task
def configure_optimizers(self, model: "Model"):
def configure_optimizers(self, model: Model):
# for tasks such as SpeakerEmbedding,
# other parameters should be added here
return torch.optim.Adam(model.parameters(), lr=1e-3)
+1 -3
View File
@@ -176,9 +176,7 @@ class SimpleEmbeddingModel(Model):
# end user does not forget to call it. note that this must
# be called at the end of __init__
if self.task is not None:
self.task.example_output_array = self.forward(
self.task.example_input_array()
)
self.task.example_output_array = self.forward(self.task.example_input_array)
def forward(self, waveforms: torch.Tensor) -> torch.Tensor:
"""
-2
View File
@@ -56,8 +56,6 @@ if __name__ == "__main__":
"Intended Audience :: Science/Research",
"License :: OSI Approved :: MIT License",
"Natural Language :: English",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Topic :: Scientific/Engineering",
],