Open kmader opened 5 years ago
Hmm, for me when I try that model I get an exception thrown from the python process
AttributeError: Layer encoder has multiple inbound nodes, hence the notion of "layer output" is ill-defined. Use `get_output_at(node_index)` instead.
The problem seems to be that there are models nested inside the vae
model. Keras MRI works by creating a wrapper model that has an output for every layer.
layer_outputs = [layer.output for layer in model.layers if not isinstance(layer, InputLayer)]
wrappedModel = Model(inputs=model.inputs, outputs=layer_outputs)
I tried recursively getting the layers in the nested model
def get_outputs(model):
outputs = []
for layer in model.layers:
if isinstance(layer, Model):
outputs = outputs + get_outputs(layer)
elif not isinstance(layer, InputLayer):
outputs.append(layer.output)
return outputs
layer_outputs = get_outputs(model)
wrappedModel = Model(inputs=model.inputs, outputs=layer_outputs)
But it seems like I can't create a model with outputs from a nested model
ValueError: Graph disconnected: cannot obtain value for tensor Tensor("z_sampling:0", shape=(?, 2), dtype=float32) at layer "z_sampling". The following previous layers were accessed without issue: ['encoder_input']
So I'm not sure how to handle nested models. Seems like an issue with other attempts to visualize Keras models too https://github.com/raghakot/keras-vis/issues/37
Yea I tried vae and got the same error as @robianmcd mentioned and tried just the encoder (which isn't nested) I got the error above
Loading just the encoder works for me in Chrome with kmri.visualize_model(encoder, x_test)
. Although the edges to the lambda layer aren't drawn. Are you using chrome?
Yes latest chrome but perhaps the pypi for keras_mri is out of date? I'll try installing it from GitHub tomorrow
I just published version 0.1.1 that has some better error handling but I'm still not sure what could be causing the issue you are having. Try it out when you get a chance and maybe do a hard refresh in chrome to make sure it gets the latest changes.
So in the updated version I get an error message as alert in the browser and the original
and then I see some of the visualizations but it fails at the draw edges step
keras-mri-app.comp.js:115 TypeError: Cannot read property 'getBoundingClientRect' of undefined
at VueComponent.get1DNodePositions (layer-renderer-1d.mixin.js:134)
at VueComponent.getNodePositions (layer.mixin.js:13)
at VueComponent.getInputLayerNodePosition (layer.mixin.js:23)
at one-to-one-edge-renderer.mixin.js:23
at Array.forEach (<anonymous>)
at VueComponent.drawEdges (one-to-one-edge-renderer.mixin.js:22)
at keras-mri-app.comp.js:101
at Array.forEach (<anonymous>)
at keras-mri-app.comp.js:100
Can you post the code you are using?
When I run
kmri.visualize_model
on the encoder from the Keras VAE example (https://keras.io/examples/variational_autoencoder/) it doesn't render. I assume it is related to thekeras.layers.Lambda
is it possible to get it to skip layers which aren't supported?