InvalidArgumentError: You must feed a value for placeholder tensor 'Placeholder' with dtype float and shape [24,10]

I’m getting the following error from the code derived from https://github.com/Gruntrexpewrus/quantum-neural-networks/blob/master/fraud_detection/fraud_detection.py

InvalidArgumentError: You must feed a value for placeholder tensor 'Placeholder' with dtype float and shape [24,10]
	 [[Node: Placeholder = Placeholder[dtype=DT_FLOAT, shape=[24,10], _device="/job:localhost/replica:0/task:0/cpu:0"]()]]

I have tried to fix this error by modifying the following line slightly:

        # Encoding classes into one-hot form
        one_hot_input = np.zeros((batch_size, 2))

        for i in range(batch_size):
            if int(classes[i]) == 0:
                # Encoded such that genuine transactions should be outputted as a photon in the first mode
                one_hot_input[i] = [1, 0]
            else:
                one_hot_input[i] = [0, 1]
                
        one_hot_input = one_hot_input.astype(float)

The array shape is already fine, so there is no need to modify it. Which portion of the code might be the cause of this datatype error and what could be the probable solution?

Hi @Abrar2652,

What versions of Strawberry Fields, TensorFlow and Python are you using?

@CatalinaAlbornoz I’m currently using Tensorflow 1.3 and Strawberryfields 0.10. Actually, the issue has been solved by restarting the kernel or resetting the placeholders. Could you please tell me if there is any other way of running this script except for Local Machine’s Jupyter Notebook? Because I’m unable to create any anaconda environment on Kaggle or Colab which is ultimately disabling me to reduce the runtime.

@Abrar2652 You could use our cloud. We have hosted Jupyter notebooks with all of the necessary libraries pre-installed. I’m not sure if your code will run in the latest Strawberry Fields and tensorflow versions but it may be worth trying it.

You can request access to the cloud here. It may take a few days for you to receive the email confirming access. If you let me know on Slack when you have requested access I can try to see if we can speed up the process to give you access.