Closed lafilletterevolution closed 3 years ago
Hi @lafilletterevolution,
Thanks for your interest in the library and your questions!
As to the first one, make sure you pass a target with 1 dimension only. The only thing you need to do is to add:
t = t.reshape(-1,)
to the target before you create the datasets and dataloaders. That'd work for both numpy arrays and torch tensors.
As to your 2nd question I'm a bit confused. There's an example of how to do it and what you get out:
valid_preds, valid_targets = learn.get_preds(ds_idx=1)
valid_preds.flatten().data, valid_targets.data
The output would look like this:
1.0354, 5.0216, 3.9414, 2.4877, 5.1141, 1.8749, 1.1920, 4.8096, 0.6502,
4.8863, 0.9522, 2.8930, 4.0097, 5.5933, 5.9315, 2.3714, 2.9296, 2.6978,
0.9772, 1.8776, 4.6022, 2.9900, 3.9207, 4.3128, 4.9796, 4.2679, 5.5830,
3.8384, 0.8922, 3.2135, 5.7431, 5.1535, 2.5613, 2.2637, 5.1737, 1.0276,
2.8652, 4.6724, 3.8183, 2.4998, 3.2545, 2.2928, 2.6861, 1.3847, 2.4677,
0.9271, 2.4401, 1.3577, 0.9259, 5.1638, 1.8561, 4.9097, 6.1943, 1.0459,
6.1193, 1.9908, 1.9740, 1.2367, 3.1562, 4.9588, 1.9142, 5.8156, 3.7834,
1.1177, 3.7022, 4.7404, 4.0850, 1.9259, 5.1798, 5.0323, 2.8950, 0.9484,
3.8553, 4.0077, 5.9068, 2.5396, 6.0177, 2.9635, 5.7630, 6.1505, 4.6146,
5.0694, 2.7898, 5.0299, 4.1939, 5.4213, 2.4789, 2.0795, 5.9228, 0.9573,
4.1209, 1.1249, 5.5639, 3.9230, 5.7608, 1.3298, 5.2989, 5.6664, 0.9779,
2.6910, 5.7851, 1.2841, 1.9815, 1.9070, 4.6295, 1.4540, 1.0274, 0.9130,
2.8109, 4.9532, 2.3928, 0.9347, 4.0593, 4.9382, 4.0294, 1.8492, 2.4316,
2.7893, 3.0276, 2.2682, 1.0443, 5.0428, 0.7717, 1.2670, 2.2958, 4.0686,
5.2443, 4.8914, 2.6054, 2.0778, 2.4967, 1.9541, 4.9731, 4.9944, 4.1486,
2.1322, 4.9756, 0.8567, 4.8160, 6.1008, 5.0327, 2.0541, 5.8026, 4.0117,
3.5269, 5.9112, 6.0859, 4.9171, 4.0207, 5.7155, 1.9125, 4.1342, 2.4422,
3.8503, 0.7314, 2.2804, 3.5096, 1.0362, 2.7871, 5.8946, 2.8460, 2.5411,
6.0164, 3.7633, 1.8908, 1.0917, 5.9010, 2.4855, 4.8978, 3.6686, 3.5271]),
tensor([4., 5., 6., 1., 4., 3., 2., 3., 3., 1., 5., 4., 3., 5., 2., 1., 5., 1.,
5., 1., 3., 4., 6., 6., 2., 3., 2., 1., 2., 5., 3., 4., 6., 5., 4., 6.,
4., 1., 4., 6., 5., 3., 2., 6., 1., 3., 5., 4., 3., 3., 3., 3., 1., 3.,
1., 2., 1., 1., 5., 2., 5., 6., 1., 6., 2., 2., 2., 3., 5., 2., 6., 4.,
1., 4., 5., 4., 2., 5., 5., 3., 1., 4., 4., 6., 2., 6., 3., 6., 6., 5.,
5., 3., 5., 4., 6., 3., 2., 6., 1., 4., 1., 6., 4., 6., 1., 6., 6., 1.,
3., 6., 1., 2., 2., 5., 2., 1., 1., 3., 5., 2., 1., 4., 5., 4., 2., 3.,
3., 3., 3., 1., 5., 1., 1., 2., 4., 5., 5., 3., 2., 2., 2., 5., 5., 4.,
2., 5., 1., 5., 6., 6., 2., 6., 4., 4., 6., 6., 5., 4., 6., 2., 4., 3.,
4., 1., 2., 4., 1., 3., 6., 3., 2., 6., 4., 2., 1., 6., 3., 5., 4., 4.]))
Please, let me know if this answers your questions.
Hi @oguiza
Many thanks for the prompt response!
For the first question, I have triple checked my target dimension, in my case y.shape is (20,), which I believe is the intended input shape into the model. However, it still gives the warning.
For the second question, what I mean is after the trained model (even though for some reason mine didn't train properly, perhaps the trial training set is just too small), I wish to deploy the model to predict additional data. However, mimicking the example nb I don't seem to be able to produce any prediction.
I have simplified my code and uploaded it to here, with the above two errors highlighted. It is by no means request for code review, it is purely to demonstrate errors I encountered. Possibly entirely my fault due to some mistakes made somewhere as a self-learner!
(Just forgot to star your repo and I'm gonna do it now)
many thanks! i suppose there are some version compatibility issue but i shall close the issue for now
Is there a way to squeeze(-1) the target size, so as to give it the extra 1 dimension? I suspect as a result of that my model is not training across epochs
Regardless of the above, it is a great library and really recommend my peers to try it out too!