The codes in this following script will be used for the publication of the following work
"Qualify-As-You-Go: Sensor Fusion of Optical and Acoustic Signatures with Contrastive Deep Learning for Multi-Material Composition Monitoring in Laser Powder Bed Fusion Process"
@any reuse of this code should be authorized by the first owner, code author
"""
#libraries to import
fromtorch.utils.dataimportDataLoader,Dataset
importnumpyasnp
importrandom
importtorch
fromtorchvisionimporttransforms
importos
importpandasaspd
classMechanism(Dataset):
"""
This class represents a dataset for a specific mechanism.
Args:
sequences (list): A list of tuples containing two sequences and a label.
Attributes:
sequences (list): A list of tuples containing two sequences and a label.
Returns:
tuple: A tuple containing the sequence and its corresponding label.
"""
def__init__(self,sequences):
self.sequences=sequences
def__len__(self):
returnlen(self.sequences)
def__getitem__(self,idx):
sequence,label=self.sequences[idx]
sequence=torch.Tensor(sequence)
sequence=sequence.view(1,-1)
label=torch.tensor(label).long()
sequence,label
returnsequence,label
defdataprocessing(df):
"""
Preprocesses the input dataframe by standardizing its values.
Args:
df (pandas.DataFrame): The input dataframe to be processed.
Returns:
pandas.DataFrame: The processed dataframe with standardized values.