Skip to content
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

[BUG Report]: Loading model error "Constructor on type 'Tensorflow.Keras.Layers.ZeroPadding2D' not found" #1279

Open
markalroberts opened this issue Dec 6, 2024 · 0 comments

Comments

@markalroberts
Copy link

markalroberts commented Dec 6, 2024

Description

When loading a model saved from python, it looks like it cannot find the constructor for Tensorflow.Keras.Layers.ZeroPadding2D owing to the fact that the single constructor that does exist has an additional optional parameter.

Reproduction Steps

Train and save a model in python: model.save('chart_type_classifier.model', save_format='tf')

Load the model in TensoFlow.Keras in c# .net

System.MissingMethodException
  HResult=0x80131513
  Message=Constructor on type 'Tensorflow.Keras.Layers.ZeroPadding2D' not found.
  Source=System.Private.CoreLib
  StackTrace:
   at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture)

Code where it blows up:

object obj2 = Assembly.Load("Tensorflow.Keras").CreateInstance("Tensorflow.Keras.Layers." + class_name, ignoreCase: true, BindingFlags.Default, null, new object[1] { obj }, null, null);

Note single argument.

Constructor that should be used but cannot be found owing to additional optional parameter:

    public ZeroPadding2D(ZeroPadding2DArgs args, string data_format = null)
      : base((LayerArgs) args)
    {
      this.data_format = conv_utils.normalize_data_format(data_format);
      this.padding = args.Padding;
      this.input_spec = new InputSpec(ndim: new int?(4));
    }

Known Workarounds

No response

Configuration and Other Information

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant