4

Currently, I am working on a model that includes deep neural networks. I am not an expert in coding nor are my colleagues.

I had a hypothesis and it seems to be working. So, I may need to write a research paper and publish it. It takes much time to go through every step and understand in detail the code modules I am using. I somehow managed to join the patches without knowing the coding-related details of each patch. I am taking the patches from the existing GitHub models.

Whenever I see the codes of research papers, they are well-organized by a team of experts. But I am alone and have no team. The research is a part of my thesis. I have no clue about organizing the code.

I have two options:

  1. not sharing the code with the journal

    In this case, if the journal asks for the code, then there is no other choice for me and I need to select the second option.

  2. posting the managed code on GitHub and then keeping the link in the research paper.

    I am afraid that the readability and the organization of the code impact the decision of reviewers.

Which option should I select now?

11
  • 51
    If you test your model with code that you don't understand, then how do you know what you're running? How do you know code is using your model? Sep 15, 2022 at 16:07
  • 43
    "Whenever I see the codes of research papers, they are well-organized by a team of experts." I wish!!!
    – qdread
    Sep 15, 2022 at 17:57
  • 12
    Is it safe to use an algorithm that "seems" to work?
    – Neuchâtel
    Sep 15, 2022 at 18:06
  • 23
    You say "I am alone and have no team" but you also refer to "my colleagues" and you say this is for your thesis, for which you should have at least an advisor if not a group.
    – shoover
    Sep 15, 2022 at 18:09
  • 11
    Recent PhD grad in the computational sciences here. To be clear, it was the general expectation for our program — and I imagine all other computational programs — that if you do not know how to program you learn in the first quarter. Seriously. Have you ever heard of a math PhD who doesn’t know math? Or a literature major who doesn’t know how to read? It is a foundational skill to any computational discipline and, while you don’t need to very talented, you do need to know how to write, structure, and organize your programs. Without those skills, your ability to succeed will be very limited.
    – Greenstick
    Sep 16, 2022 at 4:23

7 Answers 7

39

I am not an expert in coding nor are my colleagues.

This is not the first time you have made strange statements about "coding." It is true that you do not need to be an "expert in coding"; you are a researcher, not a software engineer. But understanding and organizing your codebase is something that everyone who works with code needs to do, not just the experts.

I somehow managed to join the patches without knowing the coding-related details of each patch. I am taking the patches from the existing GitHub models.

I would be terrified to publish with code I don't understand. How do you know there are no bugs? I assume you have done some "sanity checks" and things made sense....but still, having to retract a paper because the way you "somehow managed to join" them turned out to be wrong would be unfortunate.

Which option I can select now?

Poorly-written code may count against you, but refusing to share the code will probably hurt just as much. Which option you choose probably comes down to personal preference. To the extent there is a global norm, it is that sharing code is an intrinsically good thing and should be done unless there is a good reason not to (and "I did a bad job" is not a good reason).

2
  • 34
    To add to this - if you don't understand the code, do you understand the licensing of that code? You can't just relicense other people's code on a whim. If you need to relicense code that isn't originallly yours to meet with the conditions of one of the "patches" (e.g. if you have some code that came from a GPL'ed repo, your new repo must all be GPL) you might find that breaches the license of some of the other patches.
    – n00dle
    Sep 15, 2022 at 16:04
  • 1
    @n00dle - Also, how does OP know that the code he's cobbled together from random bits on GiHub isn't silently reorganising his utterly meaningless results into something that looks meaningful
    – Valorum
    Sep 18, 2022 at 7:43
29

Most likely NO

It takes much time to go through every step

This left me stunned: didn't you write the code yourself?

I am afraid that the readability and the organization of the code impact the decision of reviewers.

This is likely a correct judgement: If the code is very unstructured, it should not be published because no one — not even you — can claim to understand it.

There are two possible answers.

Understand what happens inside the modules

If by patches you mean invoked modules or libraries, usually reading the docs will be enough to "believe" that they do what they claim to do. No need to understand all of the source code for each module in detail.

If you i) don't understand the docs for the modules or ii) there are no/missing docs for the modules and you aren’t able to understand their source code, then proceed to this third option:

(3): Learn how to code or start collaborating with someone who does

Even people who know how to code can introduce bugs. Low coding quality and logical errors are a serious issue in published research code where even experienced programmers may write software with errors.

Imagine your question the other way around: "I don't really understand math, but I think I've proven something."

No, you didn't.

14

If you do not understand your code, how do you know that it is actually working, and there is no bug in your code? And how can you publish something you don't understand?

It could be possible that you use synthetic/real data that somehow made the program produce the result you wanted to see. It happened to me before when I tried to modify my correct solution by adding "random" blocks of code in my program to see what might happen.

It was definitely an incorrect solution, yet it somehow produced the correct results for some situations. However, as I tried to spend more time analyzing other settings, the "random" algorithm completely failed to work.

Looking at the results is never enough to know if the program truly works. You have to spend time analyzing your algorithm. There is no other option. Divide your code into blocks, so it will be easier to know what is going on. At least, you need a good theoretical reason to explain why your program works (and under which situations it may fail).

5

It's pretty much always the case (in situations that aren't security-sensitive, anyway) that making your code available to the public is the best thing to do.

As others have pointed out, you need to get help organising your code. Not only that, but if you're not clear on how your code works you need to do a code review with someone so that you can figure out if it really is doing what you think it's doing. That will likely include organising your code better: as a professional software developer, my first response when trying to understand badly organised code is usually to try to organise it better. (Obviously having some automated tests will help here, but regardless, "rework it so it makes more sense and then see if it still does what it's supposed to do" will both give you insight and possibly even fix problems in the code.)

If your code is freely available on GitHub you can point people at it and ask for help and suggestions. You may not get any response to requests for help, but if you keep it a secret it's certain that nobody can help you.

Also, depending on your paper, it's possible that the reviewers may need to see the code in order to review it properly. If they did need to see the code and couldn't, and let the paper go through anyway, both you and they may be doing a disservice to the entire academic community by keeping the paper from being properly reviewed.

Next time you do this, by the way, make the code publically available from the start and seek help and advice from others early on, while the code is still a small mess. That will help keep the code from growing into a huge mess.

1

Beyond what everyone else has already said, it is often useful to use domain-specific knowledge to come up with big-picture checks that, if passed, will give high confidence that large portions of the code are working correctly. This is where you, as an academic, can add value beyond standard software engineering testing practices.

For example, here are some big picture checks from my field (computational science):

  • In finite elements, you can refine the mesh, plot the error vs mesh size, and verify that the observed convergence rate matches the theoretical convergence rate.

  • In Newton's method, you can verify that the observed convergence rate is quadratic.

  • In gradient, or higher derivative, computation, you can compare the computed derivative to a sequence of finite difference derivative approximations for smaller and smaller step sizes, and verify that the two converge to each other at the expected rate.

  • In the computation of an adjoint code, you can compare (A(x),y) to (x,adjoint_A(y)) and make sure they are the same to roughly machine precision.

These kind of big picture checks are extremely valuable, because bugs (wherever those bugs are) will almost always cause the check to fail.

2
  • There is a pretty big difference between trusting well established libraries like PyTorch and grabbing random repos off of GitHub. Especially if trying to combine multiple such repos and hoping that the interfaces work the way you expect.
    – cag51
    Sep 16, 2022 at 22:22
  • @cag51 Right. So that would be a "big picture" piece of evidence that is sociological in nature rather than technical. The library is well-established, developed by experts, used by many people for many years. This would generally be a more convincing argument of correctness to a peer reviewer than a battery of unit tests that check it's functions.
    – Nick Alger
    Sep 16, 2022 at 22:36
0

There are situations where finding a solution is hard, but verifying the solution is easy. There are other cases where verifying a solution is as hard as finding one, and the only way to verify it is to try finding the solution with a different implementation, check that you get the same results, and pray that both algorithms don’t make the same mistakes.

If you can verify the results of your code, that makes problems with it much less important.

-11

On the whole, yes it's okay. If the code works, it works. Data is data even if the method of collection confusing.

Obviously it's better if you could organize it better. It will also make it more likely that people will use your code and build on your research, which means more citations of your paper. But since you assert it is impossible to organize it, that ship has sailed.

Messy code is better than no code. The critical difference is that a paper with messy code can easily be reproduced. A paper with no code is a different matter.

3
  • 8
    He/she is far from knowing if the code works.
    – Neuchâtel
    Sep 16, 2022 at 2:02
  • 2
    Code is by definition not data in the computational sense, it operates on data and can also be generative. If we were speaking about a meta analysis of code, then yes, properties of code could be data. But it’s clear that that’s not the case in this instance.
    – Greenstick
    Sep 16, 2022 at 4:32
  • 9
    Thank you for this answer, this is exactly the problematic attitude towards code that lead to this kind of scenarios and shows a complete lack of understanding of code. Software isn't a magic box that does things right. It does exactly what you tell it to do. If you tell it something wrong, it does it wrong. It's like saying "well, we don't know where the data is from or who produced it and any labels are missing, but let's just use it".
    – Mayou36
    Sep 16, 2022 at 10:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .