Skip to content

Error in d[idx_val, , , ] : The subscript out #2

@sue-shine

Description

@sue-shine

When I run the following code for file 2_1 fit_CNNIDE_stage1,:

 `while(length(epoch_order) >= N_Batch) {

train_cov_pars <- (epoch >= (28L))       # Estimate cov. pars if epoch >= 28
count <- count + 1                       # increment batch number in epoch
idx <- epoch_order[1:N_Batch]            # Take first N_Batch
epoch_order <- epoch_order[-(1:N_Batch)] # Remove first batch from list
fd <- dict(data_in = d[idx,,,],          # Creat dictionary
           data_current = dfinal[idx,,,drop=F],
           data_future = dpred[idx,,,drop=F])

if(train_cov_pars) {
  TFrun <- run(list(trainnetcov, Cost1), feed_dict = fd)
} else {
  TFrun <- run(list(trainnet, Cost1), feed_dict = fd) # Train network on its own  
}

## Get Cost for this batch
Objective[[epoch]][count] <- TFrun[[2]]

## Every 10 samples do a random validation check
if((count %% 10) == 0) {
  idx_val <- sample(idxVal, N_Batch, replace = FALSE)
  fd <- dict(data_in = d[idx_val,,,],
             data_current = dfinal[idx_val,,,drop=F],
             data_future = dpred[idx_val,,,drop=F])
  Objective_val[[epoch]][count/10] <- run(Cost1, feed_dict = fd)
  cat(paste0("Epoch ", epoch, " ...  Step ", count, 
             " ... Cost: ", Objective_val[[epoch]][count/10], "\n"))
}

Epoch_train[epoch, ] <- c(mean(Objective[[epoch]]),
                          median(Objective[[epoch]]),
                          sd(Objective[[epoch]]),
                          mad(Objective[[epoch]]))

}
}
`
##Error in d[idx_val, , , ] : The subscript out
How can I fix it? Thank you very much!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions