Problem with executing python machine learning code I found on GitHub
I need some clear instructions on how to execute some code.
Context:
This is a python machine learning peptide binding script, but you don't need to know biology to help me.
I am trying to recreate this scientific paper to test its validity and if I can use it. I work in the biotech industry and am only somewhat familiar with C# and python.
The paper is linked to a GitHub page. And the GitHub page has some instructions on how to execute the code. But every time I try to execute this code as instructed, it gives me an error. I already installed its requirements of the most updated pytorch, numpy, scikit-learn; I also switched between GPU and CPU, but no method worked. I don't know what to do at this point.
Paper Title:
&quot;Prediction of Specific TCR-Peptide Binding From Large Dictionaries of TCR-Peptide Pairs&quot; by Ido Springer, Hanan Besser. etc.
Paper's Github8 (found in the paper's abstract):
https://github.com/louzounlab/ERGO
These are the example codes I input in the terminal. The example code was found in a comment at the end of ERGO.py
GPU ver:
python ERGO.py train lstm mcpas specific cuda:0 --model_file=model.pt --train_data_file=train_data --test_data_file=test_data

GPU code results:
Traceback (most recent call last):   File &quot;D:\D Download\ERGO-master\ERGO.py&quot;, line 437, in &lt;module&gt;
    main(args)   File &quot;D:\D Download\ERGO-master\ERGO.py&quot;, line 141, in main
    model, best_auc, best_roc = lstm.train_model(train_batches, test_batches, args.device, arg, params)   File &quot;D:\D Download\ERGO-master\lstm_utils.py&quot;, line 163, in train_model
    model.to(device)   File &quot;C:\Users\username\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py&quot;, line 927, in to
    return self._apply(convert)   File &quot;C:\Users\username\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py&quot;, line 579, in _apply
    module._apply(fn)   File &quot;C:\Users\username\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py&quot;, line 602, in _apply
    param_applied = fn(param)   File &quot;C:\Users\username\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py&quot;, line 925, in convert
    return t.to(device, dtype if t.is_floating_point() or t.is_complex() else None, non_blocking)   File &quot;C:\Users\username\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\cuda\__init__.py&quot;, line 211, in _lazy_init
    raise AssertionError(&quot;Torch not compiled with CUDA enabled&quot;) AssertionError: Torch not compiled with CUDA enabled

CPU code ver (only replaced specific cuda:0 with specific cpu):
python ERGO.py train lstm mcpas specific cpu --model_file=model.pt --train_data_file=train_data --test_data_file=test_data

CPU code results:
epoch: 1 C:\Users\username\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\functional.py:1960: UserWarning: nn.functional.sigmoid is deprecated. Use torch.sigmoid instead.   warnings.warn(&quot;nn.functional.sigmoid is deprecated. Use torch.sigmoid instead.&quot;) Traceback (most recent call last):   File &quot;D:\D Download\ERGO-master\ERGO.py&quot;, line 437, in &lt;module&gt;
    main(args)   File &quot;D:\D Download\ERGO-master\ERGO.py&quot;, line 141, in main
    model, best_auc, best_roc = lstm.train_model(train_batches, test_batches, args.device, arg, params)   File &quot;D:\D Download\ERGO-master\lstm_utils.py&quot;, line 173, in train_model
    loss = train_epoch(batches, model, loss_function, optimizer, device)   File &quot;D:\D Download\ERGO-master\lstm_utils.py&quot;, line 137, in train_epoch
    loss = loss_function(probs, batch_signs)   File &quot;C:\Users\username\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py&quot;, line 1130, in _call_impl
    return forward_call(*input, **kwargs)   File &quot;C:\Users\username\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\loss.py&quot;, line 613, in forward
    return F.binary_cross_entropy(input, target, weight=self.weight, reduction=self.reduction)   File &quot;C:\Users\username\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\functional.py&quot;, line 3074, in binary_cross_entropy
    raise ValueError( ValueError: Using a target size (torch.Size([50])) that is different to the input size (torch.Size([50, 1])) is deprecated. Please ensure they have the same size.


Looking at the ValueError, it seems that what you're trying to do is deprecated in pytorch, so you have a more recent version of the package than the one it was developed in. I suggest you try
pip install pytorch 1.4.0

in command line.
I'm not familiar with pytorch but menaging tensor shapes in tensorflow is the biggest pain in the a** for me. What it actually looks like to be the problem is that the input has an extra dimension than it should, so you would have to manually reshape it.
