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

I got the same error in all test file. #1

Open
ye12121 opened this issue May 17, 2021 · 7 comments
Open

I got the same error in all test file. #1

ye12121 opened this issue May 17, 2021 · 7 comments
Assignees

Comments

@ye12121
Copy link

ye12121 commented May 17, 2021

Hi,
i try to run test file in test/layer-outputs/。by setup the basic param, i run every test file and got the following error.

Traceback (most recent call last):
File "D:/TensorFI2-master/tests/layer-outputs/fcn-fmnist.py", line 83, in
res = tfi.inject(model=model, x_test=test_images[i:i + 1], confFile=conf)
File "D:\TensorFI2-master\src\tensorfi2.py", line 42, in init
fiFunc(model, fiConf, **kwargs)
File "D:\TensorFI2-master\src\tensorfi2.py", line 146, in layer_outputs
get_pred = K.function([model.layers[randnum + 1].input], [model.layers[-1].output])
File "C:\Users\f30012263\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow\python\keras\backend.py", line 4069, in function
model = models.Model(inputs=inputs, outputs=outputs)
File "C:\Users\f30012263\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow\python\training\tracking\base.py", line 517, in _method_wrapper
result = method(self, *args, **kwargs)
File "C:\Users\f30012263\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow\python\keras\engine\functional.py", line 120, in init
self._init_graph_network(inputs, outputs)
File "C:\Users\f30012263\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow\python\training\tracking\base.py", line 517, in _method_wrapper
result = method(self, *args, **kwargs)
File "C:\Users\f30012263\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow\python\keras\engine\functional.py", line 203, in _init_graph_network
nodes, nodes_by_depth, layers, _ = _map_graph_network(
File "C:\Users\f30012263\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow\python\keras\engine\functional.py", line 985, in _map_graph_network
raise ValueError('Graph disconnected: '
ValueError: Graph disconnected: cannot obtain value for tensor KerasTensor(type_spec=TensorSpec(shape=(None, 28, 28), dtype=tf.float32, name='flatten_input'), name='flatten_input', description="created by layer 'flatten_input'") at layer "flatten". The following previous layers were accessed without issue: []

@ye12121 ye12121 changed the title I got the same error in all running test file. I got the same error in all test file. May 17, 2021
@nniranjhana nniranjhana self-assigned this May 17, 2021
@nniranjhana
Copy link
Collaborator

Hi @ye12121 thanks for trying out our tool! I am not able to reproduce this error, perhaps you could check whether you are using TensorFlow 1 version? Could you list the versions of TensorFlow and Keras you are using, along with configuration information?

@ye12121
Copy link
Author

ye12121 commented May 18, 2021

Hi @ye12121 thanks for trying out our tool! I am not able to reproduce this error, perhaps you could check whether you are using TensorFlow 1 version? Could you list the versions of TensorFlow and Keras you are using, along with configuration information?

Thank you for your reply. I am using tensorflow==2.4.1, with original sample.yaml and the other just like test.sh.
such as: python -W ignore fcn-fmnist.py confFiles/sample.yaml results-nn/b1/ 10 10
and I try all the other test py file and got the same error, like mention above.

@nniranjhana
Copy link
Collaborator

I am able to inject using the test.sh file too. Could you list your complete system configuration as I see it looks like you are on Windows with the C drive info?

This version of TensorFlow + Keras and our TensorFI 2 fault injector do not use graphs by default - that's why I was doubtful of your TensorFlow version since you have Graph disconnected and cannot obtain value for tensor in the error logs. Are you sure eager execution is enabled?

@ye12121
Copy link
Author

ye12121 commented May 19, 2021

I am able to inject using the test.sh file too. Could you list your complete system configuration as I see it looks like you are on Windows with the C drive info?

This version of TensorFlow + Keras and our TensorFI 2 fault injector do not use graphs by default - that's why I was doubtful of your TensorFlow version since you have Graph disconnected and cannot obtain value for tensor in the error logs. Are you sure eager execution is enabled?

I think I am using eager execution,since eager execution is setting enable by default on Tensorflow2 . It run on Windows and cpu-only version. Maybe the system platform cause this issue.

And I got another question about layer_outputs function. I notice you are trying to split the network and modify the middle data. If the network structure is not always linear, like inception、resnet、densenet etcetera. they got multiple input or output on some layer. Is it the function still work?

------------------ new update --------------------
I try it on ubuntu, unfortunately it still got the same error, like following:

(tf2) ye@ye-Alienware:~/workspace/TensorFI2/tests/layer-outputs$ bash test.sh
Traceback (most recent call last):
File "fcn-fmnist.py", line 79, in
res = tfi.inject(model=model, x_test=test_images[i:i+1], confFile=conf)
File "/home/ye/workspace/TensorFI2/tests/layer-outputs/../../src/tensorfi2.py", line 42, in init
fiFunc(model, fiConf, **kwargs)
File "/home/ye/workspace/TensorFI2/tests/layer-outputs/../../src/tensorfi2.py", line 145, in layer_outputs
get_pred = K.function([model.layers[randnum + 1].input], [model.layers[-1].output])
File "/home/ye/anaconda3/lib/python3.8/site-packages/tensorflow/python/keras/backend.py", line 4097, in function
model = models.Model(inputs=inputs, outputs=outputs)
File "/home/ye/anaconda3/lib/python3.8/site-packages/tensorflow/python/training/tracking/base.py", line 522, in _method_wrapper
result = method(self, *args, **kwargs)
File "/home/ye/anaconda3/lib/python3.8/site-packages/tensorflow/python/keras/engine/functional.py", line 115, in init
self._init_graph_network(inputs, outputs)
File "/home/ye/anaconda3/lib/python3.8/site-packages/tensorflow/python/training/tracking/base.py", line 522, in _method_wrapper
result = method(self, *args, **kwargs)
File "/home/ye/anaconda3/lib/python3.8/site-packages/tensorflow/python/keras/engine/functional.py", line 198, in _init_graph_network
nodes, nodes_by_depth, layers, _ = _map_graph_network(
File "/home/ye/anaconda3/lib/python3.8/site-packages/tensorflow/python/keras/engine/functional.py", line 985, in _map_graph_network
raise ValueError('Graph disconnected: '
ValueError: Graph disconnected: cannot obtain value for tensor KerasTensor(type_spec=TensorSpec(shape=(None, 28, 28), dtype=tf.float32, name='flatten_input'), name='flatten_input', description="created by layer 'flatten_input'") at layer "flatten". The following previous layers were accessed without issue: []

oh, i almost forgot, all those test py file should to be change at the beginning,
like
from src import tfi
to
from src import tensorfi2 as tfi.
if you run it without error. Is it possible you are import the old version?

@nniranjhana
Copy link
Collaborator

Hi @ye12121 thanks for checking on Ubuntu as well - yes, a change is to be committed to the test files import tensorfi2 and not tfi, however I am using the current version.. Could you try using just the command like in the README and run python nn-mnist.py confFiles/sample.yaml result/ 1 10 and check? I am not sure what's causing this issue for you since I can't reproduce it on my side.. And you're right, the current architecture works with linear models and I will soon upload a workaround for SqueezeNet that we used. I would be raising an enhancement issue for generalizing injection in other non-linear architectures as well - this would be using the inbound nodes of the Keras layers so we know which layers to connect to during dynamic injection at any layer.

@nniranjhana
Copy link
Collaborator

Here's the list of versions I use for all packages - perhaps you can check against the versions you've installed for the relevant packages in your virtual environment. You could perhaps also try to debug and see if this error occurs for all inputs, where it occurs, etc. You can use pdb maybe. I just cloned this directory to a new workspace and tried it off the rack and it worked without bugs, so I cannot debug without the bug.. you could let me know the results of debugging on your side and I'll help you figure it out from there

env.txt

@ye12121
Copy link
Author

ye12121 commented May 24, 2021

I replaced tensorflow version by 2.2 and it worked. I also try it on 2.4 and 2.5, they both got the same error. Maybe you could try it on different version of tensorflow to find out what causing this issue.

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