Running the second command returns this error. I am not clear on what is happening there.
Open
Mishaczech
opened this issue 1 year ago
•
3 comments
Running the second command returns this error. I am not clear on what is happening there.
Command: ddw fit-model --unet-params-dict chans 32 drop_prob 0.0 num_downsample_layers --adam-params-dict lr 0.0004 --num-epochs 100 --batch-size 5 --subtomo-size 64 --mw-angle 60 --gpu 0 --num-workers 3
Error:
Traceback (most recent call last) ────────────────────────────────╮
│ /cemcofsw/em/deepDeWedge/240507/bin/ddw:8 in │
│ │
│ 5 from ddw.app import main │
│ 6 if name == 'main ': │
│ 7 │ sys.argv[0] = re.sub(r'(-script.pyw|.exe)?$', '', sys.argv[0]) │
│ ❱ 8 │ sys.exit(main()) │
│ 9 │
│ │
│ ╭───────────────────────────────────── locals ─────────────────────────────────────╮ │
│ │ main = <function main at 0x7f4db165f0a0> │ │
│ │ re = <module 're' from '/cemcofsw/em/deepDeWedge/240507/lib/python3.10/re.py'> │ │
│ │ sys = <module 'sys' (built-in)> │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ /cemcofsw/em/deepDeWedge/240507/lib/python3.10/site-packages/ddw/app.py:14 in main │
│ │
│ 11 │
│ 12 │
│ 13 def main(): │
│ ❱ 14 │ app() │
│ 15 │
│ 16 │
│ 17 if name == "main ": │
│ │
│ /cemcofsw/em/deepDeWedge/240507/lib/python3.10/site-packages/typer/main.py:326 in call │
│ │
│ /cemcofsw/em/deepDeWedge/240507/lib/python3.10/site-packages/typer/main.py:309 in call │
│ │
│ /cemcofsw/em/deepDeWedge/240507/lib/python3.10/site-packages/click/core.py:1157 in call │
│ │
│ /cemcofsw/em/deepDeWedge/240507/lib/python3.10/site-packages/typer/core.py:723 in main │
│ │
│ /cemcofsw/em/deepDeWedge/240507/lib/python3.10/site-packages/typer/core.py:193 in _main │
│ │
│ /cemcofsw/em/deepDeWedge/240507/lib/python3.10/site-packages/click/core.py:1686 in invoke │
│ │
│ /cemcofsw/em/deepDeWedge/240507/lib/python3.10/site-packages/click/core.py:943 in make_context │
│ │
│ /cemcofsw/em/deepDeWedge/240507/lib/python3.10/site-packages/click/core.py:1408 in parse_args │
│ │
│ /cemcofsw/em/deepDeWedge/240507/lib/python3.10/site-packages/click/core.py:2400 in │
│ handle_parse_result │
│ │
│ /cemcofsw/em/deepDeWedge/240507/lib/python3.10/site-packages/click/core.py:2362 in process_value │
│ │
│ /cemcofsw/em/deepDeWedge/240507/lib/python3.10/site-packages/typer/main.py:1001 in wrapper │
│ │
│ /cemcofsw/em/deepDeWedge/240507/lib/python3.10/ast.py:110 in literal_eval │
│ │
│ 107 │ │ │ │ else: │
│ 108 │ │ │ │ │ return left - right │
│ 109 │ │ return _convert_signed_num(node) │
│ ❱ 110 │ return _convert(node_or_string) │
│ 111 │
│ 112 │
│ 113 def dump(node, annotate_fields=True, include_attributes=False, *, indent=None): │
│ │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ _convert = <function literal_eval.._convert at 0x7f4c4099a680> │ │
│ │ _convert_num = <function literal_eval.._convert_num at 0x7f4c4099a560> │ │
│ │ _convert_signed_num = <function literal_eval.._convert_signed_num at │ │
│ │ 0x7f4c4099a5f0> │ │
│ │ _raise_malformed_node = <function literal_eval.._raise_malformed_node at │ │
│ │ 0x7f4c4099a440> │ │
│ │ node_or_string = <ast.Name object at 0x7f4c409b4850> │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ /cemcofsw/em/deepDeWedge/240507/lib/python3.10/ast.py:109 in _convert │
│ │
│ 106 │ │ │ │ │ return left + right │
│ 107 │ │ │ │ else: │
│ 108 │ │ │ │ │ return left - right │
│ ❱ 109 │ │ return _convert_signed_num(node) │
│ 110 │ return _convert(node_or_string) │
│ 111 │
│ 112 │
│ │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ _convert = <function literal_eval.._convert at 0x7f4c4099a680> │ │
│ │ _convert_num = <function literal_eval.._convert_num at 0x7f4c4099a560> │ │
│ │ _convert_signed_num = <function literal_eval.._convert_signed_num at │ │
│ │ 0x7f4c4099a5f0> │ │
│ │ _raise_malformed_node = <function literal_eval.._raise_malformed_node at │ │
│ │ 0x7f4c4099a440> │ │
│ │ node = <ast.Name object at 0x7f4c409b4850> │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ /cemcofsw/em/deepDeWedge/240507/lib/python3.10/ast.py:83 in _convert_signed_num │
│ │
│ 80 │ │ │ │ return + operand │
│ 81 │ │ │ else: │
│ 82 │ │ │ │ return - operand │
│ ❱ 83 │ │ return _convert_num(node) │
│ 84 │ def _convert(node): │
│ 85 │ │ if isinstance(node, Constant): │
│ 86 │ │ │ return node.value │
│ │
│ ╭──────────────────────────────────── locals ────────────────────────────────────╮ │
│ │ _convert_num = <function literal_eval.._convert_num at 0x7f4c4099a560> │ │
│ │ node = <ast.Name object at 0x7f4c409b4850> │ │
│ ╰────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ /cemcofsw/em/deepDeWedge/240507/lib/python3.10/ast.py:74 in _convert_num │
│ │
│ 71 │ │ raise ValueError(msg + f': {node!r}') │
│ 72 │ def _convert_num(node): │
│ 73 │ │ if not isinstance(node, Constant) or type(node.value) not in (int, float, comple │
│ ❱ 74 │ │ │ _raise_malformed_node(node) │
│ 75 │ │ return node.value │
│ 76 │ def _convert_signed_num(node): │
│ 77 │ │ if isinstance(node, UnaryOp) and isinstance(node.op, (UAdd, USub)): │
│ │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ _raise_malformed_node = <function literal_eval.._raise_malformed_node at │ │
│ │ 0x7f4c4099a440> │ │
│ │ node = <ast.Name object at 0x7f4c409b4850> │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ /cemcofsw/em/deepDeWedge/240507/lib/python3.10/ast.py:71 in _raise_malformed_node │
│ │
│ 68 │ │ msg = "malformed node or string" │
│ 69 │ │ if lno := getattr(node, 'lineno', None): │
│ 70 │ │ │ msg += f' on line {lno}' │
│ ❱ 71 │ │ raise ValueError(msg + f': {node!r}') │
│ 72 │ def _convert_num(node): │
│ 73 │ │ if not isinstance(node, Constant) or type(node.value) not in (int, float, comple │
│ 74 │ │ │ _raise_malformed_node(node) │
│ │
│ ╭────────────────── locals ───────────────────╮ │
│ │ lno = 1 │ │
│ │ msg = 'malformed node or string on line 1' │ │
│ │ node = <ast.Name object at 0x7f4c409b4850> │ │
│ ╰─────────────────────────────────────────────╯
Originally posted by @Mishaczech in https://github.com/MLI-lab/DeepDeWedge/issues/3#issuecomment-2102261331
Hello and thanks for opening this issue!
The reason for the error is the way you specified the --unet-params-dict and --adam-params-dict arguments. They should be specified as
--unet-params-dict "{'chans': 32, 'drop_prob': 0.0, 'num_downsample_layers': 3}"
and
--adam-params-dict "{'lr': 0.0004}"
Specifying the dicts has worked for me.
In general, I recommend using DeepDeWedge with config files as shown in the tutorial . In my experience, using config files minimises the risk of syntax errors like the one you experienced.
Another thing I noticed is that in the in the command you shared, neither --subtomo-dir nor --project-dir is specified, which will result in another error. For more details, please refer to the help strings of --subtomo-dir and --project-dir, which you can access by running ddw fit-model --help.
I hope this helps. Please let me know if these tips helped you solve your problem, and don't hesitate to open another issue if you encounter any other issues.
Best,
Simon
Hello,
thanks for pointing out the config file usage. Config file makes it all smooth and easy up to now. While fitting, I got this error:
"RuntimeError: The size of tensor a (48) must match the size of tensor b (46) at non-singleton dimension 3"
It seems I have some unwanted features in input tomograms but cannot figure out what it is. I use .mrc files resulting from IMOD backprojection. To have 0 and 1 files, I split the tilts in odd and even.
Best,
Misha
Hi Misha,
glad to hear that using the config file method has solved your issue!
The error you describe reminds me of a bug in an earlier version version of the code. I'd suggest the following course of action: Could you pull the latest version of the code and see if the error still occurs? If the error persists, could you please share the full error trace along with the config file?
Best,
Simon
Closing due to inactivity.
Feel free to re-open the issue If necessary.