src.acoustools.Utilities.Targets
1from torch import Tensor 2import torch 3 4from acoustools.Utilities.Setup import device 5 6def generate_gorkov_targets(N:int,B:int=1, max_val:float=-5, min_val:float=-5, log=True) -> Tensor: 7 ''' 8 Generates a tensor of random negative Gor'kov potential values\n 9 If `B=0` will return tensor with shape of `Nx1` else will have shape `BxNx1`\n 10 :param N: Number of values per batch 11 :param B: Number of batches to produce 12 :param max_val: Maximum exponent of the value that can be generated. Default: `0` 13 :param min_val: Minimum exponent of the value that can be generated. Default: `-1e-4` 14 :return: tensor of values 15''' 16 17 if B > 0: 18 targets = torch.FloatTensor(B, N,1).uniform_(min_val,max_val).to(device) 19 else: 20 targets = torch.FloatTensor(N,1).uniform_(min_val,max_val).to(device) 21 22 23 targets = -1*torch.pow(10,targets) 24 25 return targets 26 27def generate_pressure_targets(N:int,B:int=1, max_val:float=5000, min_val:float=3000) -> Tensor: 28 ''' 29 Generates a tensor of random pressure values\\ 30 :param N: Number of values per batch 31 :param B: Number of batches to produce 32 :param max_val: Maximum value that can be generated. Default: `5000` 33 :param min_val: Minimum value that can be generated. Default: `3000` 34 Returns tensor of values 35 ''' 36 targets = torch.FloatTensor(B, N,1).uniform_(min_val,max_val).to(device) 37 return targets
def
generate_gorkov_targets( N: int, B: int = 1, max_val: float = -5, min_val: float = -5, log=True) -> torch.Tensor:
8def generate_gorkov_targets(N:int,B:int=1, max_val:float=-5, min_val:float=-5, log=True) -> Tensor: 9 ''' 10 Generates a tensor of random negative Gor'kov potential values\n 11 If `B=0` will return tensor with shape of `Nx1` else will have shape `BxNx1`\n 12 :param N: Number of values per batch 13 :param B: Number of batches to produce 14 :param max_val: Maximum exponent of the value that can be generated. Default: `0` 15 :param min_val: Minimum exponent of the value that can be generated. Default: `-1e-4` 16 :return: tensor of values 17''' 18 19 if B > 0: 20 targets = torch.FloatTensor(B, N,1).uniform_(min_val,max_val).to(device) 21 else: 22 targets = torch.FloatTensor(N,1).uniform_(min_val,max_val).to(device) 23 24 25 targets = -1*torch.pow(10,targets) 26 27 return targets
Generates a tensor of random negative Gor'kov potential values
If B=0 will return tensor with shape of Nx1 else will have shape BxNx1
Parameters
- N: Number of values per batch
- B: Number of batches to produce
- max_val: Maximum exponent of the value that can be generated. Default:
0 - min_val: Minimum exponent of the value that can be generated. Default:
-1e-4
Returns
tensor of values
def
generate_pressure_targets( N: int, B: int = 1, max_val: float = 5000, min_val: float = 3000) -> torch.Tensor:
29def generate_pressure_targets(N:int,B:int=1, max_val:float=5000, min_val:float=3000) -> Tensor: 30 ''' 31 Generates a tensor of random pressure values\\ 32 :param N: Number of values per batch 33 :param B: Number of batches to produce 34 :param max_val: Maximum value that can be generated. Default: `5000` 35 :param min_val: Minimum value that can be generated. Default: `3000` 36 Returns tensor of values 37 ''' 38 targets = torch.FloatTensor(B, N,1).uniform_(min_val,max_val).to(device) 39 return targets
Generates a tensor of random pressure values\
Parameters
- N: Number of values per batch
- B: Number of batches to produce
- max_val: Maximum value that can be generated. Default:
5000 - min_val: Minimum value that can be generated. Default:
3000Returns tensor of values