cross_entropy_loss(): argument 'target' (position 2) must be Tensor, not numpy.ndarray
Data preparation, and building the model：
dataset = datasets.load_iris()
data = dataset.data
target = dataset.target
data_tensor=torch.from_numpy(data).float()
target_tensor=torch.from_numpy(target).long()

model = nn.Sequential(
    bnn.BayesLinear(prior_mu=0, prior_sigma=0.1, in_features=4, out_features=100),
    nn.ReLU(),
    bnn.BayesLinear(prior_mu=0, prior_sigma=0.1, in_features=100, out_features=3),
)
cross_entropy_loss = nn.CrossEntropyLoss()
klloss = bnn.BKLLoss(reduction='mean', last_layer_only=False)
klweight = 0.01
optimizer = optim.Adam(model.parameters(), lr=0.01)

Run the model: Error occurred
for step in range(3000):
    models = model(data_tensor)
    cross_entropy = cross_entropy_loss(models, target)
    kl = klloss(model)
    total_cost = cross_entropy + klweight*kl

    optimizer.zero_grad()
    total_cost.backward()
    optimizer.step()
  
_, predicted = torch.max(models.data, 1)
final = target_tensor.size(0)
correct = (predicted == target_tensor).sum()
print('- Accuracy: %f %%' % (100 * float(correct) / final))
print('- CE : %2.2f, KL : %2.2f' % (cross_entropy.item(), kl.item()))

TypeError 
----&gt; 3     cross_entropy = cross_entropy_loss(models, target)
TypeError: cross_entropy_loss(): argument 'target' (position 2) must be Tensor, not numpy.ndarray

I copied code from a web-learning page, but it shows the attached error, any suggestions? many thanks !!

You used the wrong variable for target.
cross_entropy_loss(models, target)

would be
cross_entropy_loss(models, target_tensor)

