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

Question mark (?) in the model image using plot_model instead of None #41744

Closed
V2dha opened this issue Jul 26, 2020 · 5 comments
Closed

Question mark (?) in the model image using plot_model instead of None #41744

V2dha opened this issue Jul 26, 2020 · 5 comments
Assignees
Labels
comp:keras Keras related issues stat:awaiting response Status - Awaiting response from author type:support Support issues

Comments

@V2dha
Copy link
Contributor

V2dha commented Jul 26, 2020

I am using the tf.keras.utils.plot_model function to plot the model. The code is given below. Now instead of getting None for the batch sizes I am getting question mark (?). So can you please address why this is happening and how I can replace None inplace of ? question mark.

tf.keras.utils.plot_model(
model,
to_file='model2.png',
show_shapes=True,
show_layer_names=True
)

model image

@V2dha V2dha added the type:others issues not falling in bug, perfromance, support, build and install or feature label Jul 26, 2020
@jpodivin
Copy link
Contributor

What you see there is caused by this line in keras utils:

return str(shape).replace(str(None), '?')

It's actually the desired behavior.
My understanding is that the None sized dimensions are effectively variable sized, or unknown '?' when the graph is compiled.
Therefore tensor with other dimensions matching can fit. Notice how output shape of a layer and the input shape of the following layer always matches.

Now you could replace the '?' string with 'None' string, but what would it be good for? It wouldn't make it any more readable.

@V2dha
Copy link
Contributor Author

V2dha commented Jul 26, 2020

What you see there is caused by this line in keras utils:

return str(shape).replace(str(None), '?')

It's actually the desired behavior.
My understanding is that the None sized dimensions are effectively variable sized, or unknown '?' when the graph is compiled.
Therefore tensor with other dimensions matching can fit. Notice how output shape of a layer and the input shape of the following layer always matches.

Now you could replace the '?' string with 'None' string, but what would it be good for? It wouldn't make it any more readable.

Actually I am working on a research paper in which I need the image of the model architecture although it wouldn't make it any more readable from a programmer's point of view but from a layman's understanding it would atleast come out to be a tad bit readable as the '?' mark signifies as if there's an error or something is missing where as None kind of explains that I voluntary didn't add the batch sizes. Thanks for the answer though!

@jpodivin
Copy link
Contributor

Worst case scenario you can add an explanatory footnote.

@ravikyram ravikyram added comp:keras Keras related issues type:support Support issues and removed type:others issues not falling in bug, perfromance, support, build and install or feature labels Jul 27, 2020
@ravikyram
Copy link
Contributor

@V2dha

It is expected behavior.Please, see this tutorial, link for your reference.Thanks!

@ravikyram ravikyram added the stat:awaiting response Status - Awaiting response from author label Jul 27, 2020
@V2dha
Copy link
Contributor Author

V2dha commented Jul 27, 2020

Okay thanks!

@V2dha V2dha closed this as completed Jul 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:keras Keras related issues stat:awaiting response Status - Awaiting response from author type:support Support issues
Projects
None yet
Development

No branches or pull requests

3 participants