-
Notifications
You must be signed in to change notification settings - Fork 737
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integrate EBM into the pytorch framework #521
Comments
This is a novel and intriguing method: training an Energy-Based Model (EBM) as a Generalised Additive Model (GAM) inside a huge CNN or Transformer architecture. While training classic EBMs usually involves end-to-end optimisation techniques, it is possible to modify them to operate within a broader neural network architecture and train them incrementally (batch-by-batch). Here is a code example of how you can achieve this: #import necessary libries #define neural network architecture with an EBM layer
#obtain synthetic dataset and define training loop Generate synthetic datasetdef generate_data(batch_size=32): Instantiate the modelmodel = CNNWithEBM() Define loss function (energy-based loss)criterion = nn.MSELoss() Define optimizeroptimizer = optim.Adam(model.parameters(), lr=0.001) Training loopnum_epochs = 10
I hope that this helps. |
Dear Sunnycasmir,
Dear Sunnycasmir, |
Is it possible to see the code you are working on to see how I can contribute more |
Hi all,
|
Hi @JWKKWJ123 -- This kind of federated learning approach isn't something that we support out of the box. You can kind of hack it as you've discovered using merge_ebms, but the implementation isn't ideal. At some point we'll provide a better interface for building EBMs one boosting round at a time, and from batches. Your other point though about DNNs and EBMs (based on decision trees) is quite pertinent too though. The training strategies are quite different and it's not clear to me that bringing them together will result in an ideal union. An alternative approach that I might suggest would be to train the DNN as normal, then remove the last layer, and train the EBM to replace it on the now frozen DNN. Will this approach work for you? |
Dear Paul, |
Hi all,
I want to use EBM as a GAM to replace the fully connected layer at the end of a large CNN/Transformer to get interpretable output. However, I need to train the EBM like a deep learning model, with mini batches of data as input.
I would like to ask is it possible to train the model step by step (batch by batch) instead of use the end-to-end fit() function? Or are there some people already working on this?
Yours Sincerely,
Wenjie Kang
The text was updated successfully, but these errors were encountered: