The prediction results of Python model and the way of darray

Time:2020-11-22

The prediction results turned to numpy

logits=model(feature)
 
#If the model is running on a GPU
result=logits.data.cpu().numpy()  /  logits.cpu().numpy()
 
#If the model runs on the CPU
result=logits.data.numpy()  /  logits.numpy()

Turn the matrix into tensor:


np_arr = np.array([1,2,3,4])
tensor=torch.from_numpy(np_arr)

The way to transfer the prediction results of the above Python model with ndarray is the whole content shared by Xiaobian. I hope it can give you a reference, and I hope you can support developpaer more.

Recommended Today

[Q & A share the second bullet] MySQL search engine, after watching the tyrannical interviewer!

Hello, I’m younger brother. A few days ago, I shared the second interview question, the interview site of search engine in MySQL. This question is the interview at normal temperature. After reading it, I’m sure you will gain something in terms of database engine If you haven’t read my first share, you can refer to […]