scxpand.mlp.mlp_model#
Functions
|
Load a trained MLP model using unified loading utilities. |
Classes
|
Neural network head for categorical feature prediction. |
|
Fully connected neural network with layer normalization and dropout. |
|
Multi-layer perceptron model for single-cell expansion prediction. |
|
- class scxpand.mlp.mlp_model.CategoricalHead(in_dim, n_classes, hidden_dims=(16,), dropout_rate=0.3, feature_name=None)#
Neural network head for categorical feature prediction.
- Parameters:
- __init__(in_dim, n_classes, hidden_dims=(16,), dropout_rate=0.3, feature_name=None)#
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- forward(x)#
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.- Return type:
- class scxpand.mlp.mlp_model.FC_Net(in_dim, out_dim, hid_layers, dropout_rate=0.3)#
Fully connected neural network with layer normalization and dropout.
- Parameters:
- __init__(in_dim, out_dim, hid_layers, dropout_rate=0.3)#
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- forward(x)#
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class scxpand.mlp.mlp_model.MLPModel(prm, data_format, device=None)#
Multi-layer perceptron model for single-cell expansion prediction.
- Parameters:
prm (
MLPParam) – MLP parameters including layer dimensions and training configdata_format (
DataFormat) – Data format specification with gene informationdevice (
str|None(default:None)) – Device to place the model on (cuda/cpu)
- __init__(prm, data_format, device=None)#
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- class scxpand.mlp.mlp_model.ModelOutput(main_logit, categorical_logits=None)#
- __init__(main_logit, categorical_logits=None)#
- scxpand.mlp.mlp_model.load_nn_model(results_path, device)#
Load a trained MLP model using unified loading utilities.
- Parameters:
- Return type:
- Returns:
Loaded MLP model ready for inference
- Raises:
ModelLoadingError – If model loading fails
FileNotFoundError – If required files are missing