Open rodosingh opened 1 year ago
After trying to reproduce your code, I encountered two errors (Line 314)
Line 314
train_val_loss_score.append([loss,np.mean(avg_loss[:, 0]),val_fscore,test_loss, video_scores,kt,sp])
Appending the loss and test_loss (both being torch.cuda.Tensor) creates an issue (can't convert cuda tensor to numpy array) while converting them to numpy array at Line 538.
loss
test_loss
torch.cuda.Tensor
can't convert cuda tensor to numpy array
numpy
According to current version of ortools the code will be:
ortools
from ortools.algorithms.python import knapsack_solver osolver = knapsack_solver.KnapsackSolver( knapsack_solver.KNAPSACK_DYNAMIC_PROGRAMMING_SOLVER, 'test') def knapsack_ortools(values, weights, items, capacity ): scale = 1000 values = np.array(values) weights = np.array(weights) values = (values * scale).astype(np.int) weights = (weights).astype(np.int) capacity = capacity osolver.init(values.tolist(), [weights.tolist()], [capacity]) computed_value = osolver.solve() packed_items = [x for x in range(0, len(weights)) if osolver.best_solution_contains(x)] return packed_items
Thanks 😺
ThankYou MSVA guys, for making the code public and most importantly, the splits public.
After trying to reproduce your code, I encountered two errors (
Line 314
)Appending the
loss
andtest_loss
(both beingtorch.cuda.Tensor
) creates an issue (can't convert cuda tensor to numpy array
) while converting them tonumpy
array at Line 538.Additional INFO:
According to current version of
ortools
the code will be:Thanks 😺