-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[Training] How to train all the layers of the onnx training model #19186
Comments
There may be two issues. First one is related to the way you created your model. The output name in the error message suggests it is a folded constant. Folding constant means optimizing the model by computing every node taking only constant as inputs. This optimization needs to be disabled for training in order to train the original weights. Second issue is due to the fast there are two kinds of constants in an onnx models, initializers and output of "Constant" operators. These must be included as well in |
Here i have included all the graph initializer's param in the requires_grad. What else you want me to add in the requires_grad ? |
Here, I am sharing the Code for the model generation:- NUM_LAYERS = 2 encoder_input = keras.Input(shape=(MAX_SEQ_LENGTH,), dtype=tf.float32, name='encoder_input') transformer = keras.Model(inputs = encoder_input, outputs = outputs) learning_rate = 3e-5 transformer.compile(loss=loss, metrics=metrics, optimizer=optimizer) onnx_model, _ = tf2onnx.convert.from_keras(transformer) you can use these datapoints:- data = [[1.000e+00 7.780e+02 1.280e+02 7.400e+01 1.200e+01 6.300e+02 1.630e+02 label : [0., 1., 0., 0., 0.] |
This issue has been automatically marked as stale due to inactivity and will be closed in 30 days if no further activity occurs. If further support is needed, please provide an update and/or more details. |
Describe the issue
I am trying to train all the layers of the onnx model but getting below error message.
RuntimeError: C:\a_work\1\s\orttraining\orttraining\core\framework\gradient_graph_builder.cc:100 onnxruntime::training::GradientGraphBuilder::GradientGraphBuilder const_fold_opt__2874 couldn't find the consumer node.
I am using transformer encoder onnx model for training. Is it possible to train all the layers of the onnx model? Please share the reference for training all layers.
To reproduce
import onnx
from onnxruntime.training import artifacts
model_name ='ContentModel'
Load the onnx model.
onnx_model = onnx.load(f"{model_name}.onnx")
requires_grad = [param.name
for param in onnx_model.graph.initializer]
frozen_params = [ ]
Generate the training artifacts.
artifacts.generate_artifacts(
onnx_model,
requires_grad=requires_grad,
frozen_params=frozen_params,
loss=artifacts.LossType.BCEWithLogitsLoss,
optimizer=artifacts.OptimType.AdamW,
artifact_directory="training_demo"
)
Urgency
It is very urgent.
ONNX Runtime Installation
Built from Source
ONNX Runtime Version or Commit ID
1.16
PyTorch Version
2.1.2+cpu
Execution Provider
Default CPU
Execution Provider Library Version
No response
The text was updated successfully, but these errors were encountered: