Skip to content

Commit

Permalink
Fix mistakes in models' utils module's docstrings
Browse files Browse the repository at this point in the history
mcttn22 committed Jan 6, 2024
1 parent 7497441 commit 0eac4d4
Showing 4 changed files with 58 additions and 14 deletions.
25 changes: 19 additions & 6 deletions school_project/models/cpu/utils/model.py
Original file line number Diff line number Diff line change
@@ -16,12 +16,12 @@

class _Layers():
"""Manages linked list of layers."""
def __init__(self):
def __init__(self) -> None:
"""Initialise linked list."""
self.head = None
self.tail = None

def __iter__(self):
def __iter__(self) -> None:
"""Iterate forward through the network."""
current_layer = self.head
while True:
@@ -31,7 +31,7 @@ def __iter__(self):
else:
break

def __reversed__(self):
def __reversed__(self) -> None:
"""Iterate back through the network."""
current_layer = self.tail
while True:
@@ -203,12 +203,25 @@ def __repr__(self) -> str:
return (f"Layers Shape: {','.join(self.layers_shape)}\n" +
f"Learning Rate: {self.learning_rate}")

def set_running(self, value:bool):
def set_running(self, value: bool) -> None:
"""Set the running attribute to the given value.
Args:
value (bool): the value to set the running attribute to.
"""
self.__running = value

def _setup_layers(setup_values: callable) -> None:
"""Setup model layers"""
def decorator(self, *args, **kwargs):
"""Decorator that sets up model layers and sets up values of each layer
with the method given.
Args:
setup_values (callable): the method that sets up the values of each
layer.
"""
def decorator(self, *args, **kwargs) -> None:
# Check if setting up Deep Network
if len(self.hidden_layers_shape) > 0:
if self.use_relu:
11 changes: 10 additions & 1 deletion school_project/models/cpu/utils/tools.py
Original file line number Diff line number Diff line change
@@ -8,7 +8,16 @@ class ModelInterface(ABC):
"""Interface for ANN models."""
@abstractmethod
def _setup_layers(setup_values: callable) -> None:
"""Setup model layers"""
"""Decorator that sets up model layers and sets up values of each layer
with the method given.
Args:
setup_values (callable): the method that sets up the values of each
layer.
Raises:
NotImplementedError: if this method is not implemented.
"""
raise NotImplementedError

@abstractmethod
25 changes: 19 additions & 6 deletions school_project/models/gpu/utils/model.py
Original file line number Diff line number Diff line change
@@ -17,12 +17,12 @@

class _Layers():
"""Manages linked list of layers."""
def __init__(self):
def __init__(self) -> None:
"""Initialise linked list."""
self.head = None
self.tail = None

def __iter__(self):
def __iter__(self) -> None:
"""Iterate forward through the network."""
current_layer = self.head
while True:
@@ -32,7 +32,7 @@ def __iter__(self):
else:
break

def __reversed__(self):
def __reversed__(self) -> None:
"""Iterate back through the network."""
current_layer = self.tail
while True:
@@ -206,12 +206,25 @@ def __repr__(self) -> str:
return (f"Layers Shape: {','.join(self.layers_shape)}\n" +
f"Learning Rate: {self.learning_rate}")

def set_running(self, value:bool):
def set_running(self, value: bool) -> None:
"""Set the running attribute to the given value.
Args:
value (bool): the value to set the running attribute to.
"""
self.__running = value

def _setup_layers(setup_values: callable) -> None:
"""Setup model layers"""
def decorator(self, *args, **kwargs):
"""Decorator that sets up model layers and sets up values of each layer
with the method given.
Args:
setup_values (callable): the method that sets up the values of each
layer.
"""
def decorator(self, *args, **kwargs) -> None:
# Check if setting up Deep Network
if len(self.hidden_layers_shape) > 0:
if self.use_relu:
11 changes: 10 additions & 1 deletion school_project/models/gpu/utils/tools.py
Original file line number Diff line number Diff line change
@@ -9,7 +9,16 @@ class ModelInterface(ABC):
"""Interface for ANN models."""
@abstractmethod
def _setup_layers(setup_values: callable) -> None:
"""Setup model layers"""
"""Decorator that sets up model layers and sets up values of each layer
with the method given.
Args:
setup_values (callable): the method that sets up the values of each
layer.
Raises:
NotImplementedError: if this method is not implemented.
"""
raise NotImplementedError

@abstractmethod

0 comments on commit 0eac4d4

Please sign in to comment.