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

Failed to infer shape. Op: A × Bᵀ: Inner dimensions do not match up #180

Open
Gabrielllopes opened this issue Jul 28, 2020 · 2 comments

Comments

@Gabrielllopes
Copy link

Gabrielllopes commented Jul 28, 2020

Hello, I'm using my own model and I faced the follow issue while running ->
Failed to infer shape. Op: A × Bᵀ: Inner dimensions do not match up

This is the model shape -> (1, 3, 50, 50)

and the error appear when PopulateExprgraph is called

Down bellow is the code

	if _, err := os.Stat(modelfalepath); err != nil && os.IsNotExist(err) {
		//log.Fatalf("%v does not exist", *model)
		//trhow an decent error
	}
	// Create a backend receiver
	backend := gorgonnx.NewGraph()
	// Create a model and set the execution backend
	m := onnx.NewModel(backend)

	// read the onnx model
	b, err := ioutil.ReadFile(modelfalepath)
	if err != nil {
		log.Fatal(err)
	}
	// Decode it into the model
	err = m.UnmarshalBinary(b)
	if err != nil {
		log.Fatal(err)
	}

	m.SetInput(0, toTensor(img))
	// here is the error
	// if I take this if off the error will be displyed on backend.run
	fmt.Print("\n PopulateExprgraph:", backend.PopulateExprgraph())
	err = backend.Run()
	if err != nil {
		log.Fatal(err)
	}
	//m.GetOutputTensors()
	fmt.Print(m.GetOutputTensors())```

There is an way to check in backend the expected shape(or dimension) ?

Cheers for the project is amazing!

Edit:

I found and corrected this error, I had my ONNX in the following format NHWC and this codes expect NCHW (it could be nice if someone implement a flag for that).

But now I face the following probrem -> onnx: operator ReduceMean not implemented ()
@owulveryck
Copy link
Contributor

Cool, that you found the error.

About reduceMean operator, I don’t know if it is easy to implement, I have to look at it.

It is the main problem with this implementation, as there are few contribution, I can hardly follow the development of the main stream.

I am on holiday and i’ll try to have a look.
I can also help you if you want to try to implement it by yourself.

Olivier

@Gabrielllopes
Copy link
Author

Cheers buddy,

I am trying to implement reduceMean and i did not understand how to take the parameters from the network.

I saw the following code into the resharp implementation:

	n := ns[0]
	children := getOrderedChildren(g.g, n)
	err := checkCondition(children, 2)
	if err != nil {
		return err
	}

	err = a.inferShape(children[1].gorgoniaNode.Value().Data(), children[0].gorgoniaNode.Shape())
	if err != nil {
		return err
	}

my question is how do I know witch parameters the calling for reduce will pass?
Like how do I know what is on

children[1].gorgoniaNode.Value().Data()

or

children[0].gorgoniaNode.Shape()

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

2 participants