Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"IndexError: index out of range in self " while training #76

Closed
knight-fjy opened this issue Jun 12, 2024 · 2 comments
Closed

"IndexError: index out of range in self " while training #76

knight-fjy opened this issue Jun 12, 2024 · 2 comments

Comments

@knight-fjy
Copy link

Hello!
As a newcomer to using DeepH and trying out this tool for the first time, I've encountered a bit of a problem. During the training process with my data, I've run into an issue and received a program error: "IndexError: index out of range in self." I would be deeply appreciative if you could take a look at this problem and perhaps offer some guidance or possible solutions.

Best regards!

Graph data file: HGraph-h5-Sn4-5l-FromDFT.pkl
Use existing graph data file
Atomic types: [1, 6, 8, 50]
Finish loading the processed 3 structures (spinful: False, the number of atomic types: 4), cost 1 seconds
number of train set: 1
number of val set: 1
number of test set: 1
{'normalizer': False, 'boxcox': False}
Output features length of single edge: 361
The model you built has: 518170 parameters
Traceback (most recent call last):
File "/opt/miniconda3/bin/deeph-train", line 8, in
sys.exit(main())
File "/opt/miniconda3/lib/python3.9/site-packages/deeph/scripts/train.py", line 20, in main
kernel.train(train_loader, val_loader, test_loader)
File "/opt/miniconda3/lib/python3.9/site-packages/deeph/kernel.py", line 519, in train
val_losses = self.kernel_fn(val_loader, 'VAL')
File "/opt/miniconda3/lib/python3.9/site-packages/deeph/kernel.py", line 658, in kernel_fn
output = self.model(
File "/opt/miniconda3/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1051, in _call_impl
return forward_call(*input, **kwargs)
File "/opt/miniconda3/lib/python3.9/site-packages/deeph/model.py", line 621, in forward
atom_fea0 = self.embed(atom_attr)
File "/opt/miniconda3/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1051, in _call_impl
return forward_call(*input, **kwargs)
File "/opt/miniconda3/lib/python3.9/site-packages/torch/nn/modules/sparse.py", line 158, in forward
return F.embedding(
File "/opt/miniconda3/lib/python3.9/site-packages/torch/nn/functional.py", line 2044, in embedding
return torch.embedding(weight, input, padding_idx, scale_grad_by_freq, sparse)
IndexError: index out of range in self

Here's my ini:
[basic]
graph_dir = /share/3_train/result3/
save_dir = /share/3_train/result3/
raw_dir = /share/3_train/3_stru/
dataset_name = Sn4
only_get_graph = False
;choices = ['h5', 'npz']
interface = h5
target = hamiltonian
disable_cuda = False
device = cpu
;-1 for cpu_count(logical=False) // torch.cuda.device_count()
num_threads = -1
save_to_time_folder = True
save_csv = False
tb_writer = True
seed = 42
multiprocessing = 0
orbital = [{"50 50": [0, 0]}, {"50 50": [0, 1]}, {"50 50": [0, 2]}, {"50 50": [0, 3]}, {"50 50": [0, 4]}, {"50 50": [0, 5]}, {"50 50": [0, 6]}, {"50 50": [0, 7]}, {"50 50": [0, 8]}, {"50 50": [0, 9]}, {"50 50": [0, 10]}, {"50 50": [0, 11]}, {"50 50": [0, 12]}, {"50 50": [0, 13]}, {"50 50": [0, 14]}, {"50 50": [0, 15]}, {"50 50": [0, 16]}, {"50 50": [0, 17]}, {"50 50": [0, 18]}, {"50 50": [1, 0]}, {"50 50": [1, 1]}, {"50 50": [1, 2]}, {"50 50": [1, 3]}, {"50 50": [1, 4]}, {"50 50": [1, 5]}, {"50 50": [1, 6]}, {"50 50": [1, 7]}, {"50 50": [1, 8]}, {"50 50": [1, 9]}, {"50 50": [1, 10]}, {"50 50": [1, 11]}, {"50 50": [1, 12]}, {"50 50": [1, 13]}, {"50 50": [1, 14]}, {"50 50": [1, 15]}, {"50 50": [1, 16]}, {"50 50": [1, 17]}, {"50 50": [1, 18]}, {"50 50": [2, 0]}, {"50 50": [2, 1]}, {"50 50": [2, 2]}, {"50 50": [2, 3]}, {"50 50": [2, 4]}, {"50 50": [2, 5]}, {"50 50": [2, 6]}, {"50 50": [2, 7]}, {"50 50": [2, 8]}, {"50 50": [2, 9]}, {"50 50": [2, 10]}, {"50 50": [2, 11]}, {"50 50": [2, 12]}, {"50 50": [2, 13]}, {"50 50": [2, 14]}, {"50 50": [2, 15]}, {"50 50": [2, 16]}, {"50 50": [2, 17]}, {"50 50": [2, 18]}, {"50 50": [3, 0]}, {"50 50": [3, 1]}, {"50 50": [3, 2]}, {"50 50": [3, 3]}, {"50 50": [3, 4]}, {"50 50": [3, 5]}, {"50 50": [3, 6]}, {"50 50": [3, 7]}, {"50 50": [3, 8]}, {"50 50": [3, 9]}, {"50 50": [3, 10]}, {"50 50": [3, 11]}, {"50 50": [3, 12]}, {"50 50": [3, 13]}, {"50 50": [3, 14]}, {"50 50": [3, 15]}, {"50 50": [3, 16]}, {"50 50": [3, 17]}, {"50 50": [3, 18]}, {"50 50": [4, 0]}, {"50 50": [4, 1]}, {"50 50": [4, 2]}, {"50 50": [4, 3]}, {"50 50": [4, 4]}, {"50 50": [4, 5]}, {"50 50": [4, 6]}, {"50 50": [4, 7]}, {"50 50": [4, 8]}, {"50 50": [4, 9]}, {"50 50": [4, 10]}, {"50 50": [4, 11]}, {"50 50": [4, 12]}, {"50 50": [4, 13]}, {"50 50": [4, 14]}, {"50 50": [4, 15]}, {"50 50": [4, 16]}, {"50 50": [4, 17]}, {"50 50": [4, 18]}, {"50 50": [5, 0]}, {"50 50": [5, 1]}, {"50 50": [5, 2]}, {"50 50": [5, 3]}, {"50 50": [5, 4]}, {"50 50": [5, 5]}, {"50 50": [5, 6]}, {"50 50": [5, 7]}, {"50 50": [5, 8]}, {"50 50": [5, 9]}, {"50 50": [5, 10]}, {"50 50": [5, 11]}, {"50 50": [5, 12]}, {"50 50": [5, 13]}, {"50 50": [5, 14]}, {"50 50": [5, 15]}, {"50 50": [5, 16]}, {"50 50": [5, 17]}, {"50 50": [5, 18]}, {"50 50": [6, 0]}, {"50 50": [6, 1]}, {"50 50": [6, 2]}, {"50 50": [6, 3]}, {"50 50": [6, 4]}, {"50 50": [6, 5]}, {"50 50": [6, 6]}, {"50 50": [6, 7]}, {"50 50": [6, 8]}, {"50 50": [6, 9]}, {"50 50": [6, 10]}, {"50 50": [6, 11]}, {"50 50": [6, 12]}, {"50 50": [6, 13]}, {"50 50": [6, 14]}, {"50 50": [6, 15]}, {"50 50": [6, 16]}, {"50 50": [6, 17]}, {"50 50": [6, 18]}, {"50 50": [7, 0]}, {"50 50": [7, 1]}, {"50 50": [7, 2]}, {"50 50": [7, 3]}, {"50 50": [7, 4]}, {"50 50": [7, 5]}, {"50 50": [7, 6]}, {"50 50": [7, 7]}, {"50 50": [7, 8]}, {"50 50": [7, 9]}, {"50 50": [7, 10]}, {"50 50": [7, 11]}, {"50 50": [7, 12]}, {"50 50": [7, 13]}, {"50 50": [7, 14]}, {"50 50": [7, 15]}, {"50 50": [7, 16]}, {"50 50": [7, 17]}, {"50 50": [7, 18]}, {"50 50": [8, 0]}, {"50 50": [8, 1]}, {"50 50": [8, 2]}, {"50 50": [8, 3]}, {"50 50": [8, 4]}, {"50 50": [8, 5]}, {"50 50": [8, 6]}, {"50 50": [8, 7]}, {"50 50": [8, 8]}, {"50 50": [8, 9]}, {"50 50": [8, 10]}, {"50 50": [8, 11]}, {"50 50": [8, 12]}, {"50 50": [8, 13]}, {"50 50": [8, 14]}, {"50 50": [8, 15]}, {"50 50": [8, 16]}, {"50 50": [8, 17]}, {"50 50": [8, 18]}, {"50 50": [9, 0]}, {"50 50": [9, 1]}, {"50 50": [9, 2]}, {"50 50": [9, 3]}, {"50 50": [9, 4]}, {"50 50": [9, 5]}, {"50 50": [9, 6]}, {"50 50": [9, 7]}, {"50 50": [9, 8]}, {"50 50": [9, 9]}, {"50 50": [9, 10]}, {"50 50": [9, 11]}, {"50 50": [9, 12]}, {"50 50": [9, 13]}, {"50 50": [9, 14]}, {"50 50": [9, 15]}, {"50 50": [9, 16]}, {"50 50": [9, 17]}, {"50 50": [9, 18]}, {"50 50": [10, 0]}, {"50 50": [10, 1]}, {"50 50": [10, 2]}, {"50 50": [10, 3]}, {"50 50": [10, 4]}, {"50 50": [10, 5]}, {"50 50": [10, 6]}, {"50 50": [10, 7]}, {"50 50": [10, 8]}, {"50 50": [10, 9]}, {"50 50": [10, 10]}, {"50 50": [10, 11]}, {"50 50": [10, 12]}, {"50 50": [10, 13]}, {"50 50": [10, 14]}, {"50 50": [10, 15]}, {"50 50": [10, 16]}, {"50 50": [10, 17]}, {"50 50": [10, 18]}, {"50 50": [11, 0]}, {"50 50": [11, 1]}, {"50 50": [11, 2]}, {"50 50": [11, 3]}, {"50 50": [11, 4]}, {"50 50": [11, 5]}, {"50 50": [11, 6]}, {"50 50": [11, 7]}, {"50 50": [11, 8]}, {"50 50": [11, 9]}, {"50 50": [11, 10]}, {"50 50": [11, 11]}, {"50 50": [11, 12]}, {"50 50": [11, 13]}, {"50 50": [11, 14]}, {"50 50": [11, 15]}, {"50 50": [11, 16]}, {"50 50": [11, 17]}, {"50 50": [11, 18]}, {"50 50": [12, 0]}, {"50 50": [12, 1]}, {"50 50": [12, 2]}, {"50 50": [12, 3]}, {"50 50": [12, 4]}, {"50 50": [12, 5]}, {"50 50": [12, 6]}, {"50 50": [12, 7]}, {"50 50": [12, 8]}, {"50 50": [12, 9]}, {"50 50": [12, 10]}, {"50 50": [12, 11]}, {"50 50": [12, 12]}, {"50 50": [12, 13]}, {"50 50": [12, 14]}, {"50 50": [12, 15]}, {"50 50": [12, 16]}, {"50 50": [12, 17]}, {"50 50": [12, 18]}, {"50 50": [13, 0]}, {"50 50": [13, 1]}, {"50 50": [13, 2]}, {"50 50": [13, 3]}, {"50 50": [13, 4]}, {"50 50": [13, 5]}, {"50 50": [13, 6]}, {"50 50": [13, 7]}, {"50 50": [13, 8]}, {"50 50": [13, 9]}, {"50 50": [13, 10]}, {"50 50": [13, 11]}, {"50 50": [13, 12]}, {"50 50": [13, 13]}, {"50 50": [13, 14]}, {"50 50": [13, 15]}, {"50 50": [13, 16]}, {"50 50": [13, 17]}, {"50 50": [13, 18]}, {"50 50": [14, 0]}, {"50 50": [14, 1]}, {"50 50": [14, 2]}, {"50 50": [14, 3]}, {"50 50": [14, 4]}, {"50 50": [14, 5]}, {"50 50": [14, 6]}, {"50 50": [14, 7]}, {"50 50": [14, 8]}, {"50 50": [14, 9]}, {"50 50": [14, 10]}, {"50 50": [14, 11]}, {"50 50": [14, 12]}, {"50 50": [14, 13]}, {"50 50": [14, 14]}, {"50 50": [14, 15]}, {"50 50": [14, 16]}, {"50 50": [14, 17]}, {"50 50": [14, 18]}, {"50 50": [15, 0]}, {"50 50": [15, 1]}, {"50 50": [15, 2]}, {"50 50": [15, 3]}, {"50 50": [15, 4]}, {"50 50": [15, 5]}, {"50 50": [15, 6]}, {"50 50": [15, 7]}, {"50 50": [15, 8]}, {"50 50": [15, 9]}, {"50 50": [15, 10]}, {"50 50": [15, 11]}, {"50 50": [15, 12]}, {"50 50": [15, 13]}, {"50 50": [15, 14]}, {"50 50": [15, 15]}, {"50 50": [15, 16]}, {"50 50": [15, 17]}, {"50 50": [15, 18]}, {"50 50": [16, 0]}, {"50 50": [16, 1]}, {"50 50": [16, 2]}, {"50 50": [16, 3]}, {"50 50": [16, 4]}, {"50 50": [16, 5]}, {"50 50": [16, 6]}, {"50 50": [16, 7]}, {"50 50": [16, 8]}, {"50 50": [16, 9]}, {"50 50": [16, 10]}, {"50 50": [16, 11]}, {"50 50": [16, 12]}, {"50 50": [16, 13]}, {"50 50": [16, 14]}, {"50 50": [16, 15]}, {"50 50": [16, 16]}, {"50 50": [16, 17]}, {"50 50": [16, 18]}, {"50 50": [17, 0]}, {"50 50": [17, 1]}, {"50 50": [17, 2]}, {"50 50": [17, 3]}, {"50 50": [17, 4]}, {"50 50": [17, 5]}, {"50 50": [17, 6]}, {"50 50": [17, 7]}, {"50 50": [17, 8]}, {"50 50": [17, 9]}, {"50 50": [17, 10]}, {"50 50": [17, 11]}, {"50 50": [17, 12]}, {"50 50": [17, 13]}, {"50 50": [17, 14]}, {"50 50": [17, 15]}, {"50 50": [17, 16]}, {"50 50": [17, 17]}, {"50 50": [17, 18]}, {"50 50": [18, 0]}, {"50 50": [18, 1]}, {"50 50": [18, 2]}, {"50 50": [18, 3]}, {"50 50": [18, 4]}, {"50 50": [18, 5]}, {"50 50": [18, 6]}, {"50 50": [18, 7]}, {"50 50": [18, 8]}, {"50 50": [18, 9]}, {"50 50": [18, 10]}, {"50 50": [18, 11]}, {"50 50": [18, 12]}, {"50 50": [18, 13]}, {"50 50": [18, 14]}, {"50 50": [18, 15]}, {"50 50": [18, 16]}, {"50 50": [18, 17]}, {"50 50": [18, 18]}]
O_component = H
energy_component = summation
max_element = -1
statistics = False
normalizer = False
boxcox = False

[graph]
radius = -1.0
max_num_nbr = 0
create_from_DFT = True
if_lcmp_graph = True
separate_onsite = False
new_sp = False

[train]
epochs = 200
pretrained =
resume =
train_ratio = 0.34
val_ratio = 0.34
test_ratio = 0.34
early_stopping_loss = 0.0
early_stopping_loss_epoch = [0.000000, 500]
revert_then_decay = True
revert_threshold = 30
revert_decay_epoch = [500, 2000, 3000]
revert_decay_gamma = [0.4, 0.5, 0.5]
clip_grad = True
clip_grad_value = 4.2
switch_sgd = False
switch_sgd_lr = 1e-4
switch_sgd_epoch = -1

[hyperparameter]
batch_size = 3
dtype = float32
;choices = ['sgd', 'sgdm', 'adam', 'lbfgs']
optimizer = adam
;initial learning rate
learning_rate = 0.001
;choices = ['', 'MultiStepLR', 'ReduceLROnPlateau', 'CyclicLR']
lr_scheduler =
lr_milestones = []
momentum = 0.9
weight_decay = 0
criterion = MaskMSELoss
retain_edge_fea = True
lambda_Eij = 0.0
lambda_Ei = 0.1
lambda_Etot = 0.0

[network]
atom_fea_len = 64
edge_fea_len = 128
gauss_stop = 6
;The number of angular quantum numbers that spherical harmonic functions have
num_l = 5
aggr = add
distance_expansion = GaussianBasis
if_exp = True
if_MultipleLinear = False
if_edge_update = True
if_lcmp = True
normalization = LayerNorm
;choices = ['CGConv', 'GAT', 'PAINN']
atom_update_net = CGConv
trainable_gaussians = False
type_affine = False

@mzjb
Copy link
Owner

mzjb commented Jun 12, 2024

It appears from your standard output that your materials contain four elements (Atomic types: [1, 6, 8, 50]). Please first verify if all three of your materials indeed contain these four elements.

@knight-fjy
Copy link
Author

Following your advice, I have successfully resolved the issue. Thank you for your kind and friendly response!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants