Currently there is some issue about torch in my computer.
When I initiate the below code,
import torch.nn as nn
import torch.nn.functional as F
import numpy as np
import torch
It works but when I add "from torch.optim import Adam,AdamW"
import torch.nn as nn
import torch.nn.functional as F
import numpy as np
import torch
from torch.optim import Adam,AdamW
And initiate, then it gives me
AttributeError: partially initialized module 'torch' has no attribute '_jit_internal' (most likely due to a circular import)
This error. Can someone help me what is the problem?
Know what is the actual problem
I have had this multiple times before and from experience can tell you that this error can occur if you have a file named torch.py or another conflicting module name in the same directory as your script. Python may mistakenly try to import your script rather than the actual PyTorch module. If you have a file named torch.py rename it to something else and check your directory to ensure there are no conflicting filenames. Another reason this can happen is a circular import (where a module tries to import itself). Try checking any imports you use if they import themselves. I hope this helps you!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With