What's the difference between the two? You can read one, but you can't read the other.
Code 2 tried to code https://github.com/graykode/ALBERT-Pytorch
Code 1 cuts out the part where the error occurred
Code 1 moves
import json
json.load(open('config/pretrain.json'))
print ("aaaa")
Code 2 doesn't work
class Config (NamedTuple):
""" Hyperparameters for training ""
seed: int = 3431 # random seed
batch_size —int=8
lr —int=5e-5#learning rate
n_epochs: int=10#the number of epoch
# `warm up`period=warmup(0.1)*total_steps
# linear increasing learning rate from zero to the specified value (5e-5)
warmup:float=0.1
save_steps: int=100# interval for saving model
total_steps: int = 100000 # total number of steps to train
@classmethod
def from_json(cls, file):# load config from json file
return cls(**json.load(open(file, "r"))))
Error Content I have verified that the file variable (directory) is the same as code 1
Traceback (most recent call last):
File "pretrain.py", line 285, in<module>
main(args=args)
File "pretrain.py", line 211, in main
cfg = train.Config.from_json(args.train_cfg)
File "C:\Users\PC_User\newAI2022y08y23d\project\ALBERT-Pytorch-master\train.py", line 32, in from_json
return cls(**json.load(open(file, "r"))))
FileNotFoundError: [Errno2] No such file or directory: "'config/pretrain.json'"
FileNotFoundError: [Errno2] No such file or directory: "'config/pretrain.json'"
If the error message is correct, it appears that there is an unnecessary '
around the filename.
1025 Uncaught (inpromise) Error on Electron: An object could not be cloned
981 Error in x, y, and format string must not be None
861 GDB gets version error when attempting to debug with the Presense SDK (IDE)
1504 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
© 2025 OneMinuteCode. All rights reserved.