You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I was trying to inject faults with TensorFI2 in different pre-trained models in Keras with the ImageNet dataset. I was able to successfully inject faults with VGG16, VGG19, and MobileNet. However, when injecting faults in Resnet50, Resnet101, Resnet152, NasnetMobile, etc, I got the following error.
Traceback (most recent call last):
File "resnet-imagenet.py", line 42, in <module>
res = tfi.inject(model=model, x_test=image, confFile=conf)
File "/home/sabuj/TensorFI2/src/tensorfi2.py", line 42, in __init__
fiFunc(model, fiConf, **kwargs)
File "/home/sabuj/TensorFI2/src/tensorfi2.py", line 223, in layer_outputs
pred = get_pred([fiLayerOutputs])
File "/home/sabuj/anaconda3/envs/tfi2/lib/python3.7/site-packages/tensorflow/python/keras/backend.py", line 3792, in __call__
outputs = self._graph_fn(*converted_inputs)
File "/home/sabuj/anaconda3/envs/tfi2/lib/python3.7/site-packages/tensorflow/python/eager/function.py", line 1605, in __call__
return self._call_impl(args, kwargs)
File "/home/sabuj/anaconda3/envs/tfi2/lib/python3.7/site-packages/tensorflow/python/eager/function.py", line 1645, in _call_impl
return self._call_flat(args, self.captured_inputs, cancellation_manager)
File "/home/sabuj/anaconda3/envs/tfi2/lib/python3.7/site-packages/tensorflow/python/eager/function.py", line 1746, in _call_flat
ctx, args, cancellation_manager=cancellation_manager))
File "/home/sabuj/anaconda3/envs/tfi2/lib/python3.7/site-packages/tensorflow/python/eager/function.py", line 598, in call
ctx=ctx)
File "/home/sabuj/anaconda3/envs/tfi2/lib/python3.7/site-packages/tensorflow/python/eager/execute.py", line 60, in quick_execute
inputs, attrs, num_outputs)
tensorflow.python.framework.errors_impl.InvalidArgumentError: You must feed a value for placeholder tensor 'input_1' with dtype float and shape [?,224,224,3]
[[node input_1 (defined at /home/sabuj/TensorFI2/src/tensorfi2.py:222) ]] [Op:__inference_keras_scratch_graph_10471]
The problem is, this error is not generating every time. When the layer number for fault injection is low, there is no error. For example, when I injected faults in the first 6 layers for Resnet50, there was no error(I changed random layer number to fixed layer number in tensorfi2 implementation for finding the reason). When injecting faults in the later layers, most of the time, it throws errors.
I ran the experiments/layer_outputs/resnet-imagenet.py file for my testing. However, I simplified it for ease of my testing. I am adding the code snippet here.
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
import tensorflow as tf
import numpy as np
import random
from tensorflow.keras.preprocessing.image import load_img, img_to_array
from tensorflow.keras.applications.resnet import preprocess_input, decode_predictions
import time, sys, math
from src import tensorfi2 as tfi
model = tf.keras.applications.ResNet50(
include_top=True, weights='imagenet', input_tensor=None,
input_shape=None, pooling=None, classes=1000)
model.compile(optimizer='sgd', loss='categorical_crossentropy')
#model.save_weights('h5/vgg16-trained.h5')
path = 'dog.jpg'
image = load_img(path, target_size=(224, 224))
image = img_to_array(image)
image = image.reshape((1, image.shape[0], image.shape[1], image.shape[2]))
image = preprocess_input(image)
out = model.predict(image)
label = decode_predictions(out)
label = label[0][0]
print(label)
conf = 'confFiles/sample.yaml'
numFaults = 10
for i in range(numFaults):
# model.load_weights('h5/resnet-trained.h5')
image = load_img(path, target_size=(224, 224))
image = img_to_array(image)
image = image.reshape((1, image.shape[0], image.shape[1], image.shape[2]))
image = preprocess_input(image)
res = tfi.inject(model=model, x_test=image, confFile=conf)
Here 'dog.jpg' is a random file, that I used for testing. The confFiles/sample.yml is added below.
Target: layer_outputs
Mode: single
Type: bitflips
Amount: 1
Bit: N
I tried this both in windows and ubuntu 20.04. I used both conda and pip environments for my experiment. I found the same issue in all the cases. I am adding my env file for reference.
Thanks @sabuj7177 for the detailed observations and logs. I think this is related to issue #2. I am not working on this presently, but if you are able to fix this, feel free to send a commit and I can take a look.
Hi, I was trying to inject faults with TensorFI2 in different pre-trained models in Keras with the ImageNet dataset. I was able to successfully inject faults with VGG16, VGG19, and MobileNet. However, when injecting faults in Resnet50, Resnet101, Resnet152, NasnetMobile, etc, I got the following error.
The problem is, this error is not generating every time. When the layer number for fault injection is low, there is no error. For example, when I injected faults in the first 6 layers for Resnet50, there was no error(I changed random layer number to fixed layer number in tensorfi2 implementation for finding the reason). When injecting faults in the later layers, most of the time, it throws errors.
I ran the experiments/layer_outputs/resnet-imagenet.py file for my testing. However, I simplified it for ease of my testing. I am adding the code snippet here.
Here 'dog.jpg' is a random file, that I used for testing. The confFiles/sample.yml is added below.
I tried this both in windows and ubuntu 20.04. I used both conda and pip environments for my experiment. I found the same issue in all the cases. I am adding my env file for reference.
Any solution of this error will be very helpful for me. Thank you.
The text was updated successfully, but these errors were encountered: