I was following the Variational Classifier tutorial posted on Pennylane to teach myself the fundamentals of Pennylane. Unfortunately, received an unexpected error. Not sure if the recent development changed something or not.
Code
weights = weights_init
bias = bias_init
for it in range(100):
batch_index = np.random.randint(0, len(x), (batch_size,))
X_batch = X[batch_index]
Y_batch = Y[batch_index]
weights, bias = opt.step(cost, weights, bias, X=X_batch, Y=Y_batch)
# compute accuracy
predictions = [np.sign(variational_classifier(weights, bias, x)) for x in x]
current_cost = cost(weights, bias, X, Y)
acc = accuracy(Y, predictions)
print(f"Iter: {it+1:4d} | Cost: {current_cost:0.7f} | Accuracy: {acc:0.7f}")
Produced Error
TypeError Traceback (most recent call last)
<ipython-input-27-1016c24e2061> in <cell line: 3>()
5 X_batch = X[batch_index]
6 Y_batch = Y[batch_index]
----> 7 weights, bias = opt.step(cost, weights, bias, X=X_batch, Y=Y_batch)
8
9 # compute accuracy
7 frames
/usr/local/lib/python3.10/dist-packages/autograd/wrap_util.py in unary_f(x)
13 else:
14 subargs = subvals(args, zip(argnum, x))
---> 15 return fun(*subargs, **kwargs)
16 if isinstance(argnum, int):
17 x = args[argnum]
TypeError: cost() got an unexpected keyword argument 'X'
Tutorial Following: Variational classifier | PennyLane Demos
Can someone help me? how to resolve this?