python set set intersection & is empty because elements are of different numpy types

set(np.arange(0,10)) is of type numpy.int32

The dataloader loads tensor, converts it to np.array(index), and the output is of numpy.int64 type

So set(np.arange(0,10)) & set(np.array(index)) are empty,

需要 set( np.array(index).astype(np.int32) )

The set collections look the same, but the types are different

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325730274&siteId=291194637