# Update the values based on node’s attributes
if data.get('device_type') == 'transistor':
values[0] = data.get('w_value', 0)
values[1] = data.get('l_value', 0)
elif data.get('device_type') == 'passive' and data.get('vertex_type') == 'C':
values[2] = data.get('value', 0)
elif data.get('device_type') == 'current_source':
values[3] = data.get('dc_value', 0)
elif data.get('device_type') == 'voltage_source':
values[4] = data.get('dc_value', 0)
# Prepare one-hot encoded features
device_type = [1] if data.get('device_type') in ['transistor', 'passive', 'current_source', 'voltage_source'] else [0]
device_map = {'NMOS': [1, 0, 0, 0, 0, 0], 'PMOS': [0, 1, 0, 0, 0, 0], 'C': [0, 0, 1, 0, 0, 0],
'I': [0, 0, 0, 1, 0, 0], 'V': [0, 0, 0, 0, 1, 0], 'net': [0, 0, 0, 0, 0, 1]
}
component_index_map = {'M0': [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 'M1': [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0],
'M2': [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0], 'M3': [0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0],
'M4': [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0], 'M5': [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0],
'M6': [0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0], 'M7': [0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0],
'C0': [0]*8 + [1, 0, 0],
'I0': [0]*9 + [1, 0], 'V1': [0]*10 + [1], 'net': [0]*11}
component_onehot = component_index_map.get(node, [0]*11) # Defaults to all zeros for unmatched nodes
device_onehot = device_map.get(data.get('vertex_type', 'net'), [0, 0, 0, 0, 0, 1]) # Defaults to 'net'
# Construct the feature vector
feature_vector = device_type + device_onehot + component_onehot + values
node_features.append(feature_vector)
print("node_features", node_features)
# Convert to Tensor
node_features_tensor = torch.FloatTensor(node_features)
return node_features_tensor