Added support for RNN
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import os
|
||||
import ast
|
||||
from typing import Optional, Tuple, Union
|
||||
import random
|
||||
import numpy as np
|
||||
import torch
|
||||
|
||||
|
||||
@@ -137,3 +139,17 @@ def str_to_dim(dim: str) -> Optional[Union[int, Tuple[int, ...]]]:
|
||||
|
||||
return None
|
||||
|
||||
def set_seed(seed=42) -> None:
|
||||
"""
|
||||
Sets seed for random number generation.
|
||||
|
||||
Args:
|
||||
seed (int): Initial seed.
|
||||
"""
|
||||
torch.manual_seed(seed)
|
||||
np.random.seed(seed)
|
||||
random.seed(seed)
|
||||
if torch.cuda.is_available():
|
||||
torch.cuda.manual_seed_all(seed)
|
||||
torch.backends.cudnn.deterministic = True
|
||||
torch.backends.cudnn.benchmark = False
|
||||
Reference in New Issue
Block a user