-
Notifications
You must be signed in to change notification settings - Fork 283
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
Conflict Arguments Between R and Python: Error in py_call_impl(callable, call_args$unnamed, call_args$named) #1427
Comments
Hi, I'm happy to help, but I would need a smaller MRE (minimal reproducible example). Can you please extract out the relevant code that generates the error from that project and place in this thread? Ideally it would be something I can copy+paste+run to see the same error. How was tensorflow installed? Did you use |
Hi @t-kalinowski, thank you soooo much for your help. I don't know where exactly the code that generates the error, since it is a long function (around 1000 lines or so), and I just ran from the exact original code (I didn't change anything, except for Also, I did use the Here's the code for generating the model function: Codelibrary(keras)
library(plyr)
library(reticulate)
#py_install("h5py")
#py_install("tensorflow")
library(tensorflow)
##############################################################################################
### Definition of the function neural_network_train_embedding ###
### This function is used to train the neural network and to extract the embedding weights ###
##############################################################################################
### Define the function neural_network_train_embedding
### We have the following inputs:
### seed1 = set the seed for reproducibility
### neurons = number of neurons in the hidden layers of the neural network
### dropout_rates = dropout rates for the past payment information
### starting_values = starting values for the neural network parameters
### network_weights = weights of the individual parts of the loss function
neural_network_train_embedding <- function(seed1, neurons, dropout_rates, starting_values, network_weights){
### Seed
# use_session_with_seed(seed1)
set_random_seed(seed1)
### Dropout
dropout_1_1 <- layer_dropout(rate = dropout_rates[1])
dropout_1_2 <- layer_dropout(rate = dropout_rates[1])
dropout_1_3 <- layer_dropout(rate = dropout_rates[1])
dropout_1_4 <- layer_dropout(rate = dropout_rates[1])
dropout_1_5 <- layer_dropout(rate = dropout_rates[1])
dropout_1_6 <- layer_dropout(rate = dropout_rates[1])
dropout_1_7 <- layer_dropout(rate = dropout_rates[1])
dropout_1_8 <- layer_dropout(rate = dropout_rates[1])
dropout_1_9 <- layer_dropout(rate = dropout_rates[1])
dropout_1_10 <- layer_dropout(rate = dropout_rates[1])
dropout_2_1 <- layer_dropout(rate = dropout_rates[2])
dropout_2_2 <- layer_dropout(rate = dropout_rates[2])
dropout_2_3 <- layer_dropout(rate = dropout_rates[2])
dropout_2_4 <- layer_dropout(rate = dropout_rates[2])
dropout_2_5 <- layer_dropout(rate = dropout_rates[2])
dropout_2_6 <- layer_dropout(rate = dropout_rates[2])
dropout_2_7 <- layer_dropout(rate = dropout_rates[2])
dropout_2_8 <- layer_dropout(rate = dropout_rates[2])
dropout_2_9 <- layer_dropout(rate = dropout_rates[2])
dropout_3_1 <- layer_dropout(rate = dropout_rates[3])
dropout_3_2 <- layer_dropout(rate = dropout_rates[3])
dropout_3_3 <- layer_dropout(rate = dropout_rates[3])
dropout_3_4 <- layer_dropout(rate = dropout_rates[3])
dropout_3_5 <- layer_dropout(rate = dropout_rates[3])
dropout_3_6 <- layer_dropout(rate = dropout_rates[3])
dropout_3_7 <- layer_dropout(rate = dropout_rates[3])
dropout_3_8 <- layer_dropout(rate = dropout_rates[3])
dropout_4_1 <- layer_dropout(rate = dropout_rates[4])
dropout_4_2 <- layer_dropout(rate = dropout_rates[4])
dropout_4_3 <- layer_dropout(rate = dropout_rates[4])
dropout_4_4 <- layer_dropout(rate = dropout_rates[4])
dropout_4_5 <- layer_dropout(rate = dropout_rates[4])
dropout_4_6 <- layer_dropout(rate = dropout_rates[4])
dropout_4_7 <- layer_dropout(rate = dropout_rates[4])
dropout_5_1 <- layer_dropout(rate = dropout_rates[5])
dropout_5_2 <- layer_dropout(rate = dropout_rates[5])
dropout_5_3 <- layer_dropout(rate = dropout_rates[5])
dropout_5_4 <- layer_dropout(rate = dropout_rates[5])
dropout_5_5 <- layer_dropout(rate = dropout_rates[5])
dropout_5_6 <- layer_dropout(rate = dropout_rates[5])
dropout_6_1 <- layer_dropout(rate = dropout_rates[6])
dropout_6_2 <- layer_dropout(rate = dropout_rates[6])
dropout_6_3 <- layer_dropout(rate = dropout_rates[6])
dropout_6_4 <- layer_dropout(rate = dropout_rates[6])
dropout_6_5 <- layer_dropout(rate = dropout_rates[6])
dropout_7_1 <- layer_dropout(rate = dropout_rates[7])
dropout_7_2 <- layer_dropout(rate = dropout_rates[7])
dropout_7_3 <- layer_dropout(rate = dropout_rates[7])
dropout_7_4 <- layer_dropout(rate = dropout_rates[7])
dropout_8_1 <- layer_dropout(rate = dropout_rates[8])
dropout_8_2 <- layer_dropout(rate = dropout_rates[8])
dropout_8_3 <- layer_dropout(rate = dropout_rates[8])
dropout_9_1 <- layer_dropout(rate = dropout_rates[9])
dropout_9_2 <- layer_dropout(rate = dropout_rates[9])
dropout_10_1 <- layer_dropout(rate = dropout_rates[10])
### Inputs
dropout <- layer_input(shape = c(1), dtype = 'int32', name = 'dropout')
cc <- layer_input(shape = c(1), dtype = 'int32', name = 'cc')
AY <- layer_input(shape = c(1), dtype = 'int32', name = 'AY')
AQ <- layer_input(shape = c(1), dtype = 'int32', name = 'AQ')
age <- layer_input(shape = c(1), dtype = 'int32', name = 'age')
inj_part <- layer_input(shape = c(1), dtype = 'int32', name = 'inj_part')
RepDel <- layer_input(shape = c(1), dtype = 'int32', name = 'RepDel')
Time_Known01 <- layer_input(shape = c(1), dtype = 'float32', name = 'Time_Known01')
Time_Known02 <- layer_input(shape = c(1), dtype = 'float32', name = 'Time_Known02')
Time_Known03 <- layer_input(shape = c(1), dtype = 'float32', name = 'Time_Known03')
Time_Known04 <- layer_input(shape = c(1), dtype = 'float32', name = 'Time_Known04')
Time_Known05 <- layer_input(shape = c(1), dtype = 'float32', name = 'Time_Known05')
Time_Known06 <- layer_input(shape = c(1), dtype = 'float32', name = 'Time_Known06')
Time_Known07 <- layer_input(shape = c(1), dtype = 'float32', name = 'Time_Known07')
Time_Known08 <- layer_input(shape = c(1), dtype = 'float32', name = 'Time_Known08')
Time_Known09 <- layer_input(shape = c(1), dtype = 'float32', name = 'Time_Known09')
Time_Known10 <- layer_input(shape = c(1), dtype = 'float32', name = 'Time_Known10')
Time_Known11 <- layer_input(shape = c(1), dtype = 'float32', name = 'Time_Known11')
Pay00Info <- layer_input(shape = c(1), dtype = 'int32', name = 'Pay00Info')
Pay01Info <- layer_input(shape = c(1), dtype = 'int32', name = 'Pay01Info')
Pay02Info <- layer_input(shape = c(1), dtype = 'int32', name = 'Pay02Info')
Pay03Info <- layer_input(shape = c(1), dtype = 'int32', name = 'Pay03Info')
Pay04Info <- layer_input(shape = c(1), dtype = 'int32', name = 'Pay04Info')
Pay05Info <- layer_input(shape = c(1), dtype = 'int32', name = 'Pay05Info')
Pay06Info <- layer_input(shape = c(1), dtype = 'int32', name = 'Pay06Info')
Pay07Info <- layer_input(shape = c(1), dtype = 'int32', name = 'Pay07Info')
Pay08Info <- layer_input(shape = c(1), dtype = 'int32', name = 'Pay08Info')
Pay09Info <- layer_input(shape = c(1), dtype = 'int32', name = 'Pay09Info')
Pay10Info <- layer_input(shape = c(1), dtype = 'int32', name = 'Pay10Info')
Time_Predict_Indicator00 <- layer_input(shape = c(1), dtype = 'float32', name = 'Time_Predict_Indicator00')
Time_Predict_Indicator01 <- layer_input(shape = c(1), dtype = 'float32', name = 'Time_Predict_Indicator01')
Time_Predict_Indicator02 <- layer_input(shape = c(1), dtype = 'float32', name = 'Time_Predict_Indicator02')
Time_Predict_Indicator03 <- layer_input(shape = c(1), dtype = 'float32', name = 'Time_Predict_Indicator03')
Time_Predict_Indicator04 <- layer_input(shape = c(1), dtype = 'float32', name = 'Time_Predict_Indicator04')
Time_Predict_Indicator05 <- layer_input(shape = c(1), dtype = 'float32', name = 'Time_Predict_Indicator05')
Time_Predict_Indicator06 <- layer_input(shape = c(1), dtype = 'float32', name = 'Time_Predict_Indicator06')
Time_Predict_Indicator07 <- layer_input(shape = c(1), dtype = 'float32', name = 'Time_Predict_Indicator07')
Time_Predict_Indicator08 <- layer_input(shape = c(1), dtype = 'float32', name = 'Time_Predict_Indicator08')
Time_Predict_Indicator09 <- layer_input(shape = c(1), dtype = 'float32', name = 'Time_Predict_Indicator09')
Time_Predict_Indicator10 <- layer_input(shape = c(1), dtype = 'float32', name = 'Time_Predict_Indicator10')
Time_Predict_Indicator11 <- layer_input(shape = c(1), dtype = 'float32', name = 'Time_Predict_Indicator11')
Time_Predict_Payment00 <- layer_input(shape = c(1), dtype = 'float32', name = 'Time_Predict_Payment00')
Time_Predict_Payment01 <- layer_input(shape = c(1), dtype = 'float32', name = 'Time_Predict_Payment01')
Time_Predict_Payment02 <- layer_input(shape = c(1), dtype = 'float32', name = 'Time_Predict_Payment02')
Time_Predict_Payment03 <- layer_input(shape = c(1), dtype = 'float32', name = 'Time_Predict_Payment03')
Time_Predict_Payment04 <- layer_input(shape = c(1), dtype = 'float32', name = 'Time_Predict_Payment04')
Time_Predict_Payment05 <- layer_input(shape = c(1), dtype = 'float32', name = 'Time_Predict_Payment05')
Time_Predict_Payment06 <- layer_input(shape = c(1), dtype = 'float32', name = 'Time_Predict_Payment06')
Time_Predict_Payment07 <- layer_input(shape = c(1), dtype = 'float32', name = 'Time_Predict_Payment07')
Time_Predict_Payment08 <- layer_input(shape = c(1), dtype = 'float32', name = 'Time_Predict_Payment08')
Time_Predict_Payment09 <- layer_input(shape = c(1), dtype = 'float32', name = 'Time_Predict_Payment09')
Time_Predict_Payment10 <- layer_input(shape = c(1), dtype = 'float32', name = 'Time_Predict_Payment10')
Time_Predict_Payment11 <- layer_input(shape = c(1), dtype = 'float32', name = 'Time_Predict_Payment11')
### Embeddings
dropout_embed <- dropout %>%
layer_embedding(input_dim = 1, output_dim = 1, trainable=FALSE, input_length = 1,
weights=list(matrix(c(1)))) %>%
layer_flatten
cc_embed_input <- cc %>%
layer_embedding(input_dim = 51, output_dim = 1, input_length = 1) %>%
layer_flatten
cc_embed_output <- cc %>%
layer_embedding(input_dim = 51, output_dim = 1, input_length = 1) %>%
layer_flatten
AY_embed_input <- AY %>%
layer_embedding(input_dim = 12, output_dim = 1, input_length = 1) %>%
layer_flatten
AY_embed_output <- AY %>%
layer_embedding(input_dim = 12, output_dim = 1, input_length = 1) %>%
layer_flatten
AQ_embed_input <- AQ %>%
layer_embedding(input_dim = 4, output_dim = 1, input_length = 1) %>%
layer_flatten
AQ_embed_output <- AQ %>%
layer_embedding(input_dim = 4, output_dim = 1, input_length = 1) %>%
layer_flatten
age_embed_input <- age %>%
layer_embedding(input_dim = 12, output_dim = 1, input_length = 1) %>%
layer_flatten
age_embed_output <- age %>%
layer_embedding(input_dim = 12, output_dim = 1, input_length = 1) %>%
layer_flatten
inj_part_embed_input <- inj_part %>%
layer_embedding(input_dim = 46, output_dim = 1, input_length = 1) %>%
layer_flatten
inj_part_embed_output <- inj_part %>%
layer_embedding(input_dim = 46, output_dim = 1, input_length = 1) %>%
layer_flatten
RepDel_embed_input <- RepDel %>%
layer_embedding(input_dim = 3, output_dim = 1, input_length = 1) %>%
layer_flatten
RepDel_embed_output <- RepDel %>%
layer_embedding(input_dim = 3, output_dim = 1, input_length = 1) %>%
layer_flatten
Pay00Info_embed_input <- Pay00Info %>%
layer_embedding(input_dim = 6, output_dim = 1, input_length = 1) %>%
layer_flatten
Pay00Info_embed_output <- Pay00Info %>%
layer_embedding(input_dim = 6, output_dim = 1, input_length = 1) %>%
layer_flatten
Pay01Info_embed_input <- Pay01Info %>%
layer_embedding(input_dim = 6, output_dim = 1, input_length = 1) %>%
layer_flatten
Pay01Info_embed_output <- Pay01Info %>%
layer_embedding(input_dim = 6, output_dim = 1, input_length = 1) %>%
layer_flatten
Pay02Info_embed_input <- Pay02Info %>%
layer_embedding(input_dim = 6, output_dim = 1, input_length = 1) %>%
layer_flatten
Pay02Info_embed_output <- Pay02Info %>%
layer_embedding(input_dim = 6, output_dim = 1, input_length = 1) %>%
layer_flatten
Pay03Info_embed_input <- Pay03Info %>%
layer_embedding(input_dim = 6, output_dim = 1, input_length = 1) %>%
layer_flatten
Pay03Info_embed_output <- Pay03Info %>%
layer_embedding(input_dim = 6, output_dim = 1, input_length = 1) %>%
layer_flatten
Pay04Info_embed_input <- Pay04Info %>%
layer_embedding(input_dim = 6, output_dim = 1, input_length = 1) %>%
layer_flatten
Pay04Info_embed_output <- Pay04Info %>%
layer_embedding(input_dim = 6, output_dim = 1, input_length = 1) %>%
layer_flatten
Pay05Info_embed_input <- Pay05Info %>%
layer_embedding(input_dim = 6, output_dim = 1, input_length = 1) %>%
layer_flatten
Pay05Info_embed_output <- Pay05Info %>%
layer_embedding(input_dim = 6, output_dim = 1, input_length = 1) %>%
layer_flatten
Pay06Info_embed_input <- Pay06Info %>%
layer_embedding(input_dim = 6, output_dim = 1, input_length = 1) %>%
layer_flatten
Pay06Info_embed_output <- Pay06Info %>%
layer_embedding(input_dim = 6, output_dim = 1, input_length = 1) %>%
layer_flatten
Pay07Info_embed_input <- Pay07Info %>%
layer_embedding(input_dim = 6, output_dim = 1, input_length = 1) %>%
layer_flatten
Pay07Info_embed_output <- Pay07Info %>%
layer_embedding(input_dim = 6, output_dim = 1, input_length = 1) %>%
layer_flatten
Pay08Info_embed_input <- Pay08Info %>%
layer_embedding(input_dim = 6, output_dim = 1, input_length = 1) %>%
layer_flatten
Pay08Info_embed_output <- Pay08Info %>%
layer_embedding(input_dim = 6, output_dim = 1, input_length = 1) %>%
layer_flatten
Pay09Info_embed_input <- Pay09Info %>%
layer_embedding(input_dim = 6, output_dim = 1, input_length = 1) %>%
layer_flatten
Pay09Info_embed_output <- Pay09Info %>%
layer_embedding(input_dim = 6, output_dim = 1, input_length = 1) %>%
layer_flatten
Pay10Info_embed_input <- Pay10Info %>%
layer_embedding(input_dim = 6, output_dim = 1, input_length = 1) %>%
layer_flatten
Pay10Info_embed_output <- Pay10Info %>%
layer_embedding(input_dim = 6, output_dim = 1, input_length = 1) %>%
layer_flatten
### Time 00 - Time 11
features_input <- list(cc_embed_input, AQ_embed_input, age_embed_input, inj_part_embed_input, RepDel_embed_input) %>%
layer_concatenate
AY_embed_input_NN <- AY_embed_input %>%
layer_dense(units = neurons[1], activation='linear')
features_output <- list(cc_embed_output, AQ_embed_output, age_embed_output, inj_part_embed_output, RepDel_embed_output) %>%
layer_concatenate
AY_output_indicator <- AY_embed_output %>%
layer_dense(units = 1, activation='linear', name="AY_output_indicator",
weights = list(array(0,dim=c(1,1)),array(0,dim=c(1))))
AY_output_mean <- AY_embed_output %>%
layer_dense(units = 1, activation='linear', name="AY_output_mean",
weights = list(array(0,dim=c(1,1)),array(0,dim=c(1))))
### Time 00
hidden_0_pre <- features_input %>%
layer_dense(units=neurons[1], activation='linear')
hidden_0 <- list(hidden_0_pre, AY_embed_input_NN) %>%
layer_add %>%
layer_dense(units=neurons[1], activation='tanh', trainable = FALSE,
weights = list(diag(1,neurons[1]),array(0,dim=c(neurons[1])))) %>%
layer_dense(units=neurons[2], activation='tanh')
payment_indicator00_pre <- hidden_0 %>%
layer_dense(units=neurons[3], activation='tanh')
payment_indicator00_pre2 <- list(payment_indicator00_pre, features_output) %>%
layer_concatenate(name = "pay_ind00") %>%
layer_dense(units = 1, activation='linear',
weights = list(array(rep(0,neurons[3]+5),dim=c(neurons[3]+5,1)),array(log(starting_values[1,1]/(1-starting_values[1,1])),dim=c(1))))
payment_indicator00 <- list(payment_indicator00_pre2, AY_output_indicator) %>%
layer_add %>%
layer_dense(units = 1, activation = 'sigmoid', trainable = FALSE,
weights = list(array(1,dim=c(1,1)),array(0,dim=c(1))))
payment_mean00_pre <- hidden_0 %>%
layer_dense(units=neurons[3], activation='tanh')
payment_mean00_pre2 <- list(payment_mean00_pre, features_output) %>%
layer_concatenate(name = "pay_mean00") %>%
layer_dense(units = 1, activation='linear',
weights = list(array(rep(0,neurons[3]+5),dim=c(neurons[3]+5,1)),array(starting_values[1,2],dim=c(1))))
payment_mean00 <- list(payment_mean00_pre2, AY_output_mean) %>%
layer_add %>%
layer_dense(units = 1, activation = 'linear', trainable = FALSE,
weights = list(array(1,dim=c(1,1)),array(0,dim=c(1))))
### Time 01
hidden_1_pre <- list(features_input, Pay00Info_embed_input) %>%
layer_concatenate() %>%
layer_dense(units=neurons[1], activation='linear')
hidden_1 <- list(hidden_1_pre, AY_embed_input_NN) %>%
layer_add %>%
layer_dense(units=neurons[1], activation='tanh', trainable = FALSE,
weights = list(diag(1,neurons[1]),array(0,dim=c(neurons[1])))) %>%
layer_dense(units=neurons[2], activation='tanh')
payment_indicator01_pre <- hidden_1 %>%
layer_dense(units=neurons[3], activation='tanh')
payment_indicator01_pre2 <- list(payment_indicator01_pre, features_output, Pay00Info_embed_output) %>%
layer_concatenate(name = "pay_ind01") %>%
layer_dense(units = 1, activation='linear',
weights = list(array(rep(0,neurons[3]+6),dim=c(neurons[3]+6,1)),array(log(starting_values[2,1]/(1-starting_values[2,1])),dim=c(1))))
payment_indicator01 <- list(payment_indicator01_pre2, AY_output_indicator) %>%
layer_add %>%
layer_dense(units = 1, activation = 'sigmoid', trainable = FALSE,
weights = list(array(1,dim=c(1,1)),array(0,dim=c(1))))
payment_mean01_pre <- hidden_1 %>%
layer_dense(units=neurons[3], activation='tanh')
payment_mean01_pre2 <- list(payment_mean01_pre, features_output, Pay00Info_embed_output) %>%
layer_concatenate(name = "pay_mean01") %>%
layer_dense(units = 1, activation='linear',
weights = list(array(rep(0,neurons[3]+6),dim=c(neurons[3]+6,1)),array(starting_values[2,2],dim=c(1))))
payment_mean01 <- list(payment_mean01_pre2, AY_output_mean) %>%
layer_add %>%
layer_dense(units = 1, activation = 'linear', trainable = FALSE,
weights = list(array(1,dim=c(1,1)),array(0,dim=c(1))))
### Time 02
dropout_1_10_applied <- dropout_embed %>%
dropout_1_10(training = TRUE)
Pay01Info_embed_input_dropout_02 <- list(Pay01Info_embed_input, dropout_1_10_applied, Time_Known01) %>%
layer_multiply()
Pay01Info_embed_output_dropout_02 <- list(Pay01Info_embed_output, dropout_1_10_applied, Time_Known01) %>%
layer_multiply()
hidden_2_pre <- list(features_input, Pay00Info_embed_input, Pay01Info_embed_input_dropout_02) %>%
layer_concatenate() %>%
layer_dense(units=neurons[1], activation='linear')
hidden_2 <- list(hidden_2_pre, AY_embed_input_NN) %>%
layer_add %>%
layer_dense(units=neurons[1], activation='tanh', trainable = FALSE,
weights = list(diag(1,neurons[1]),array(0,dim=c(neurons[1])))) %>%
layer_dense(units=neurons[2], activation='tanh')
payment_indicator02_pre <- hidden_2 %>%
layer_dense(units=neurons[3], activation='tanh')
payment_indicator02_pre2 <- list(payment_indicator02_pre, features_output, Pay00Info_embed_output, Pay01Info_embed_output_dropout_02) %>%
layer_concatenate(name = "pay_ind02") %>%
layer_dense(units = 1, activation='linear',
weights = list(array(rep(0,neurons[3]+7),dim=c(neurons[3]+7,1)),array(log(starting_values[3,1]/(1-starting_values[3,1])),dim=c(1))))
payment_indicator02 <- list(payment_indicator02_pre2, AY_output_indicator) %>%
layer_add %>%
layer_dense(units = 1, activation = 'sigmoid', trainable = FALSE,
weights = list(array(1,dim=c(1,1)),array(0,dim=c(1))))
payment_mean02_pre <- hidden_2 %>%
layer_dense(units=neurons[3], activation='tanh')
payment_mean02_pre2 <- list(payment_mean02_pre, features_output, Pay00Info_embed_output, Pay01Info_embed_output_dropout_02) %>%
layer_concatenate(name = "pay_mean02") %>%
layer_dense(units = 1, activation='linear',
weights = list(array(rep(0,neurons[3]+7),dim=c(neurons[3]+7,1)),array(starting_values[3,2],dim=c(1))))
payment_mean02 <- list(payment_mean02_pre2, AY_output_mean) %>%
layer_add %>%
layer_dense(units = 1, activation = 'linear', trainable = FALSE,
weights = list(array(1,dim=c(1,1)),array(0,dim=c(1))))
### Time 03
dropout_1_9_applied <- dropout_embed %>%
dropout_1_9(training = TRUE)
dropout_2_9_applied <- dropout_embed %>%
dropout_2_9(training = TRUE)
Pay01Info_embed_input_dropout_03 <- list(Pay01Info_embed_input, dropout_2_9_applied, Time_Known01) %>%
layer_multiply()
Pay01Info_embed_output_dropout_03 <- list(Pay01Info_embed_output, dropout_2_9_applied, Time_Known01) %>%
layer_multiply()
Pay02Info_embed_input_dropout_03 <- list(Pay02Info_embed_input, dropout_2_9_applied, dropout_1_9_applied, Time_Known02) %>%
layer_multiply()
Pay02Info_embed_output_dropout_03 <- list(Pay02Info_embed_output, dropout_2_9_applied, dropout_1_9_applied, Time_Known02) %>%
layer_multiply()
hidden_3_pre <- list(features_input, Pay00Info_embed_input, Pay01Info_embed_input_dropout_03, Pay02Info_embed_input_dropout_03) %>%
layer_concatenate() %>%
layer_dense(units=neurons[1], activation='linear')
hidden_3 <- list(hidden_3_pre, AY_embed_input_NN) %>%
layer_add %>%
layer_dense(units=neurons[1], activation='tanh', trainable = FALSE,
weights = list(diag(1,neurons[1]),array(0,dim=c(neurons[1])))) %>%
layer_dense(units=neurons[2], activation='tanh')
payment_indicator03_pre <- hidden_3 %>%
layer_dense(units=neurons[3], activation='tanh')
payment_indicator03_pre2 <- list(payment_indicator03_pre, features_output, Pay00Info_embed_output, Pay01Info_embed_output_dropout_03, Pay02Info_embed_output_dropout_03) %>%
layer_concatenate(name = "pay_ind03") %>%
layer_dense(units = 1, activation='linear',
weights = list(array(rep(0,neurons[3]+8),dim=c(neurons[3]+8,1)),array(log(starting_values[4,1]/(1-starting_values[4,1])),dim=c(1))))
payment_indicator03 <- list(payment_indicator03_pre2, AY_output_indicator) %>%
layer_add %>%
layer_dense(units = 1, activation = 'sigmoid', trainable = FALSE,
weights = list(array(1,dim=c(1,1)),array(0,dim=c(1))))
payment_mean03_pre <- hidden_3 %>%
layer_dense(units=neurons[3], activation='tanh')
payment_mean03_pre2 <- list(payment_mean03_pre, features_output, Pay00Info_embed_output, Pay01Info_embed_output_dropout_03, Pay02Info_embed_output_dropout_03) %>%
layer_concatenate(name = "pay_mean03") %>%
layer_dense(units = 1, activation='linear',
weights = list(array(rep(0,neurons[3]+8),dim=c(neurons[3]+8,1)),array(starting_values[4,2],dim=c(1))))
payment_mean03 <- list(payment_mean03_pre2, AY_output_mean) %>%
layer_add %>%
layer_dense(units = 1, activation = 'linear', trainable = FALSE,
weights = list(array(1,dim=c(1,1)),array(0,dim=c(1))))
### Time 04
dropout_1_8_applied <- dropout_embed %>%
dropout_1_8(training = TRUE)
dropout_2_8_applied <- dropout_embed %>%
dropout_2_8(training = TRUE)
dropout_3_8_applied <- dropout_embed %>%
dropout_3_8(training = TRUE)
Pay01Info_embed_input_dropout_04 <- list(Pay01Info_embed_input, dropout_3_8_applied, Time_Known01) %>%
layer_multiply()
Pay01Info_embed_output_dropout_04 <- list(Pay01Info_embed_output, dropout_3_8_applied, Time_Known01) %>%
layer_multiply()
Pay02Info_embed_input_dropout_04 <- list(Pay02Info_embed_input, dropout_3_8_applied, dropout_2_8_applied, Time_Known02) %>%
layer_multiply()
Pay02Info_embed_output_dropout_04 <- list(Pay02Info_embed_output, dropout_3_8_applied, dropout_2_8_applied, Time_Known02) %>%
layer_multiply()
Pay03Info_embed_input_dropout_04 <- list(Pay03Info_embed_input, dropout_3_8_applied, dropout_2_8_applied, dropout_1_8_applied, Time_Known03) %>%
layer_multiply()
Pay03Info_embed_output_dropout_04 <- list(Pay03Info_embed_output, dropout_3_8_applied, dropout_2_8_applied, dropout_1_8_applied, Time_Known03) %>%
layer_multiply()
hidden_4_pre <- list(features_input, Pay00Info_embed_input, Pay01Info_embed_input_dropout_04, Pay02Info_embed_input_dropout_04, Pay03Info_embed_input_dropout_04) %>%
layer_concatenate() %>%
layer_dense(units=neurons[1], activation='linear')
hidden_4 <- list(hidden_4_pre, AY_embed_input_NN) %>%
layer_add %>%
layer_dense(units=neurons[1], activation='tanh', trainable = FALSE,
weights = list(diag(1,neurons[1]),array(0,dim=c(neurons[1])))) %>%
layer_dense(units=neurons[2], activation='tanh')
payment_indicator04_pre <- hidden_4 %>%
layer_dense(units=neurons[3], activation='tanh')
payment_indicator04_pre2 <- list(payment_indicator04_pre, features_output, Pay00Info_embed_output, Pay01Info_embed_output_dropout_04, Pay02Info_embed_output_dropout_04, Pay03Info_embed_output_dropout_04) %>%
layer_concatenate(name = "pay_ind04") %>%
layer_dense(units = 1, activation='linear',
weights = list(array(rep(0,neurons[3]+9),dim=c(neurons[3]+9,1)),array(log(starting_values[5,1]/(1-starting_values[5,1])),dim=c(1))))
payment_indicator04 <- list(payment_indicator04_pre2, AY_output_indicator) %>%
layer_add %>%
layer_dense(units = 1, activation = 'sigmoid', trainable = FALSE,
weights = list(array(1,dim=c(1,1)),array(0,dim=c(1))))
payment_mean04_pre <- hidden_4 %>%
layer_dense(units=neurons[3], activation='tanh')
payment_mean04_pre2 <- list(payment_mean04_pre, features_output, Pay00Info_embed_output, Pay01Info_embed_output_dropout_04, Pay02Info_embed_output_dropout_04, Pay03Info_embed_output_dropout_04) %>%
layer_concatenate(name = "pay_mean04") %>%
layer_dense(units = 1, activation='linear',
weights = list(array(rep(0,neurons[3]+9),dim=c(neurons[3]+9,1)),array(starting_values[5,2],dim=c(1))))
payment_mean04 <- list(payment_mean04_pre2, AY_output_mean) %>%
layer_add %>%
layer_dense(units = 1, activation = 'linear', trainable = FALSE,
weights = list(array(1,dim=c(1,1)),array(0,dim=c(1))))
### Time 05
dropout_1_7_applied <- dropout_embed %>%
dropout_1_7(training = TRUE)
dropout_2_7_applied <- dropout_embed %>%
dropout_2_7(training = TRUE)
dropout_3_7_applied <- dropout_embed %>%
dropout_3_7(training = TRUE)
dropout_4_7_applied <- dropout_embed %>%
dropout_4_7(training = TRUE)
Pay01Info_embed_input_dropout_05 <- list(Pay01Info_embed_input, dropout_4_7_applied, Time_Known01) %>%
layer_multiply()
Pay01Info_embed_output_dropout_05 <- list(Pay01Info_embed_output, dropout_4_7_applied, Time_Known01) %>%
layer_multiply()
Pay02Info_embed_input_dropout_05 <- list(Pay02Info_embed_input, dropout_4_7_applied, dropout_3_7_applied, Time_Known02) %>%
layer_multiply()
Pay02Info_embed_output_dropout_05 <- list(Pay02Info_embed_output, dropout_4_7_applied, dropout_3_7_applied, Time_Known02) %>%
layer_multiply()
Pay03Info_embed_input_dropout_05 <- list(Pay03Info_embed_input, dropout_4_7_applied, dropout_3_7_applied, dropout_2_7_applied, Time_Known03) %>%
layer_multiply()
Pay03Info_embed_output_dropout_05 <- list(Pay03Info_embed_output, dropout_4_7_applied, dropout_3_7_applied, dropout_2_7_applied, Time_Known03) %>%
layer_multiply()
Pay04Info_embed_input_dropout_05 <- list(Pay04Info_embed_input, dropout_4_7_applied, dropout_3_7_applied, dropout_2_7_applied, dropout_1_7_applied, Time_Known04) %>%
layer_multiply()
Pay04Info_embed_output_dropout_05 <- list(Pay04Info_embed_output, dropout_4_7_applied, dropout_3_7_applied, dropout_2_7_applied, dropout_1_7_applied, Time_Known04) %>%
layer_multiply()
hidden_5_pre <- list(features_input, Pay00Info_embed_input, Pay01Info_embed_input_dropout_05, Pay02Info_embed_input_dropout_05, Pay03Info_embed_input_dropout_05, Pay04Info_embed_input_dropout_05) %>%
layer_concatenate() %>%
layer_dense(units=neurons[1], activation='linear')
hidden_5 <- list(hidden_5_pre, AY_embed_input_NN) %>%
layer_add %>%
layer_dense(units=neurons[1], activation='tanh', trainable = FALSE,
weights = list(diag(1,neurons[1]),array(0,dim=c(neurons[1])))) %>%
layer_dense(units=neurons[2], activation='tanh')
payment_indicator05_pre <- hidden_5 %>%
layer_dense(units=neurons[3], activation='tanh')
payment_indicator05_pre2 <- list(payment_indicator05_pre, features_output, Pay00Info_embed_output, Pay01Info_embed_output_dropout_05, Pay02Info_embed_output_dropout_05, Pay03Info_embed_output_dropout_05, Pay04Info_embed_output_dropout_05) %>%
layer_concatenate(name = "pay_ind05") %>%
layer_dense(units = 1, activation='linear',
weights = list(array(rep(0,neurons[3]+10),dim=c(neurons[3]+10,1)),array(log(starting_values[6,1]/(1-starting_values[6,1])),dim=c(1))))
payment_indicator05 <- list(payment_indicator05_pre2, AY_output_indicator) %>%
layer_add %>%
layer_dense(units = 1, activation = 'sigmoid', trainable = FALSE,
weights = list(array(1,dim=c(1,1)),array(0,dim=c(1))))
payment_mean05_pre <- hidden_5 %>%
layer_dense(units=neurons[3], activation='tanh')
payment_mean05_pre2 <- list(payment_mean05_pre, features_output, Pay00Info_embed_output, Pay01Info_embed_output_dropout_05, Pay02Info_embed_output_dropout_05, Pay03Info_embed_output_dropout_05, Pay04Info_embed_output_dropout_05) %>%
layer_concatenate(name = "pay_mean05") %>%
layer_dense(units = 1, activation='linear',
weights = list(array(rep(0,neurons[3]+10),dim=c(neurons[3]+10,1)),array(starting_values[6,2],dim=c(1))))
payment_mean05 <- list(payment_mean05_pre2, AY_output_mean) %>%
layer_add %>%
layer_dense(units = 1, activation = 'linear', trainable = FALSE,
weights = list(array(1,dim=c(1,1)),array(0,dim=c(1))))
### Time 06
dropout_1_6_applied <- dropout_embed %>%
dropout_1_6(training = TRUE)
dropout_2_6_applied <- dropout_embed %>%
dropout_2_6(training = TRUE)
dropout_3_6_applied <- dropout_embed %>%
dropout_3_6(training = TRUE)
dropout_4_6_applied <- dropout_embed %>%
dropout_4_6(training = TRUE)
dropout_5_6_applied <- dropout_embed %>%
dropout_5_6(training = TRUE)
Pay01Info_embed_input_dropout_06 <- list(Pay01Info_embed_input, dropout_5_6_applied, Time_Known01) %>%
layer_multiply()
Pay01Info_embed_output_dropout_06 <- list(Pay01Info_embed_output, dropout_5_6_applied, Time_Known01) %>%
layer_multiply()
Pay02Info_embed_input_dropout_06 <- list(Pay02Info_embed_input, dropout_5_6_applied, dropout_4_6_applied, Time_Known02) %>%
layer_multiply()
Pay02Info_embed_output_dropout_06 <- list(Pay02Info_embed_output, dropout_5_6_applied, dropout_4_6_applied, Time_Known02) %>%
layer_multiply()
Pay03Info_embed_input_dropout_06 <- list(Pay03Info_embed_input, dropout_5_6_applied, dropout_4_6_applied, dropout_3_6_applied, Time_Known03) %>%
layer_multiply()
Pay03Info_embed_output_dropout_06 <- list(Pay03Info_embed_output, dropout_5_6_applied, dropout_4_6_applied, dropout_3_6_applied, Time_Known03) %>%
layer_multiply()
Pay04Info_embed_input_dropout_06 <- list(Pay04Info_embed_input, dropout_5_6_applied, dropout_4_6_applied, dropout_3_6_applied, dropout_2_6_applied, Time_Known04) %>%
layer_multiply()
Pay04Info_embed_output_dropout_06 <- list(Pay04Info_embed_output, dropout_5_6_applied, dropout_4_6_applied, dropout_3_6_applied, dropout_2_6_applied, Time_Known04) %>%
layer_multiply()
Pay05Info_embed_input_dropout_06 <- list(Pay05Info_embed_input, dropout_5_6_applied, dropout_4_6_applied, dropout_3_6_applied, dropout_2_6_applied, dropout_1_6_applied, Time_Known05) %>%
layer_multiply()
Pay05Info_embed_output_dropout_06 <- list(Pay05Info_embed_output, dropout_5_6_applied, dropout_4_6_applied, dropout_3_6_applied, dropout_2_6_applied, dropout_1_6_applied, Time_Known05) %>%
layer_multiply()
hidden_6_pre <- list(features_input, Pay00Info_embed_input, Pay01Info_embed_input_dropout_06, Pay02Info_embed_input_dropout_06, Pay03Info_embed_input_dropout_06, Pay04Info_embed_input_dropout_06, Pay05Info_embed_input_dropout_06) %>%
layer_concatenate() %>%
layer_dense(units=neurons[1], activation='linear')
hidden_6 <- list(hidden_6_pre, AY_embed_input_NN) %>%
layer_add %>%
layer_dense(units=neurons[1], activation='tanh', trainable = FALSE,
weights = list(diag(1,neurons[1]),array(0,dim=c(neurons[1])))) %>%
layer_dense(units=neurons[2], activation='tanh')
payment_indicator06_pre <- hidden_6 %>%
layer_dense(units=neurons[3], activation='tanh')
payment_indicator06_pre2 <- list(payment_indicator06_pre, features_output, Pay00Info_embed_output, Pay01Info_embed_output_dropout_06, Pay02Info_embed_output_dropout_06, Pay03Info_embed_output_dropout_06, Pay04Info_embed_output_dropout_06, Pay05Info_embed_output_dropout_06) %>%
layer_concatenate(name = "pay_ind06") %>%
layer_dense(units = 1, activation='linear',
weights = list(array(rep(0,neurons[3]+11),dim=c(neurons[3]+11,1)),array(log(starting_values[7,1]/(1-starting_values[7,1])),dim=c(1))))
payment_indicator06 <- list(payment_indicator06_pre2, AY_output_indicator) %>%
layer_add %>%
layer_dense(units = 1, activation = 'sigmoid', trainable = FALSE,
weights = list(array(1,dim=c(1,1)),array(0,dim=c(1))))
payment_mean06_pre <- hidden_6 %>%
layer_dense(units=neurons[3], activation='tanh')
payment_mean06_pre2 <- list(payment_mean06_pre, features_output, Pay00Info_embed_output, Pay01Info_embed_output_dropout_06, Pay02Info_embed_output_dropout_06, Pay03Info_embed_output_dropout_06, Pay04Info_embed_output_dropout_06, Pay05Info_embed_output_dropout_06) %>%
layer_concatenate(name = "pay_mean06") %>%
layer_dense(units = 1, activation='linear',
weights = list(array(rep(0,neurons[3]+11),dim=c(neurons[3]+11,1)),array(starting_values[7,2],dim=c(1))))
payment_mean06 <- list(payment_mean06_pre2, AY_output_mean) %>%
layer_add %>%
layer_dense(units = 1, activation = 'linear', trainable = FALSE,
weights = list(array(1,dim=c(1,1)),array(0,dim=c(1))))
### Time 07
dropout_1_5_applied <- dropout_embed %>%
dropout_1_5(training = TRUE)
dropout_2_5_applied <- dropout_embed %>%
dropout_2_5(training = TRUE)
dropout_3_5_applied <- dropout_embed %>%
dropout_3_5(training = TRUE)
dropout_4_5_applied <- dropout_embed %>%
dropout_4_5(training = TRUE)
dropout_5_5_applied <- dropout_embed %>%
dropout_5_5(training = TRUE)
dropout_6_5_applied <- dropout_embed %>%
dropout_6_5(training = TRUE)
Pay01Info_embed_input_dropout_07 <- list(Pay01Info_embed_input, dropout_6_5_applied, Time_Known01) %>%
layer_multiply()
Pay01Info_embed_output_dropout_07 <- list(Pay01Info_embed_output, dropout_6_5_applied, Time_Known01) %>%
layer_multiply()
Pay02Info_embed_input_dropout_07 <- list(Pay02Info_embed_input, dropout_6_5_applied, dropout_5_5_applied, Time_Known02) %>%
layer_multiply()
Pay02Info_embed_output_dropout_07 <- list(Pay02Info_embed_output, dropout_6_5_applied, dropout_5_5_applied, Time_Known02) %>%
layer_multiply()
Pay03Info_embed_input_dropout_07 <- list(Pay03Info_embed_input, dropout_6_5_applied, dropout_5_5_applied, dropout_4_5_applied, Time_Known03) %>%
layer_multiply()
Pay03Info_embed_output_dropout_07 <- list(Pay03Info_embed_output, dropout_6_5_applied, dropout_5_5_applied, dropout_4_5_applied, Time_Known03) %>%
layer_multiply()
Pay04Info_embed_input_dropout_07 <- list(Pay04Info_embed_input, dropout_6_5_applied, dropout_5_5_applied, dropout_4_5_applied, dropout_3_5_applied, Time_Known04) %>%
layer_multiply()
Pay04Info_embed_output_dropout_07 <- list(Pay04Info_embed_output, dropout_6_5_applied, dropout_5_5_applied, dropout_4_5_applied, dropout_3_5_applied, Time_Known04) %>%
layer_multiply()
Pay05Info_embed_input_dropout_07 <- list(Pay05Info_embed_input, dropout_6_5_applied, dropout_5_5_applied, dropout_4_5_applied, dropout_3_5_applied, dropout_2_5_applied, Time_Known05) %>%
layer_multiply()
Pay05Info_embed_output_dropout_07 <- list(Pay05Info_embed_output, dropout_6_5_applied, dropout_5_5_applied, dropout_4_5_applied, dropout_3_5_applied, dropout_2_5_applied, Time_Known05) %>%
layer_multiply()
Pay06Info_embed_input_dropout_07 <- list(Pay06Info_embed_input, dropout_6_5_applied, dropout_5_5_applied, dropout_4_5_applied, dropout_3_5_applied, dropout_2_5_applied, dropout_1_5_applied, Time_Known06) %>%
layer_multiply()
Pay06Info_embed_output_dropout_07 <- list(Pay06Info_embed_output, dropout_6_5_applied, dropout_5_5_applied, dropout_4_5_applied, dropout_3_5_applied, dropout_2_5_applied, dropout_1_5_applied, Time_Known06) %>%
layer_multiply()
hidden_7_pre <- list(features_input, Pay00Info_embed_input, Pay01Info_embed_input_dropout_07, Pay02Info_embed_input_dropout_07, Pay03Info_embed_input_dropout_07, Pay04Info_embed_input_dropout_07, Pay05Info_embed_input_dropout_07, Pay06Info_embed_input_dropout_07) %>%
layer_concatenate() %>%
layer_dense(units=neurons[1], activation='linear')
hidden_7 <- list(hidden_7_pre, AY_embed_input_NN) %>%
layer_add %>%
layer_dense(units=neurons[1], activation='tanh', trainable = FALSE,
weights = list(diag(1,neurons[1]),array(0,dim=c(neurons[1])))) %>%
layer_dense(units=neurons[2], activation='tanh')
payment_indicator07_pre <- hidden_7 %>%
layer_dense(units=neurons[3], activation='tanh')
payment_indicator07_pre2 <- list(payment_indicator07_pre, features_output, Pay00Info_embed_output, Pay01Info_embed_output_dropout_07, Pay02Info_embed_output_dropout_07, Pay03Info_embed_output_dropout_07, Pay04Info_embed_output_dropout_07, Pay05Info_embed_output_dropout_07, Pay06Info_embed_output_dropout_07) %>%
layer_concatenate(name = "pay_ind07") %>%
layer_dense(units = 1, activation='linear',
weights = list(array(rep(0,neurons[3]+12),dim=c(neurons[3]+12,1)),array(log(starting_values[8,1]/(1-starting_values[8,1])),dim=c(1))))
payment_indicator07 <- list(payment_indicator07_pre2, AY_output_indicator) %>%
layer_add %>%
layer_dense(units = 1, activation = 'sigmoid', trainable = FALSE,
weights = list(array(1,dim=c(1,1)),array(0,dim=c(1))))
payment_mean07_pre <- hidden_7 %>%
layer_dense(units=neurons[3], activation='tanh')
payment_mean07_pre2 <- list(payment_mean07_pre, features_output, Pay00Info_embed_output, Pay01Info_embed_output_dropout_07, Pay02Info_embed_output_dropout_07, Pay03Info_embed_output_dropout_07, Pay04Info_embed_output_dropout_07, Pay05Info_embed_output_dropout_07, Pay06Info_embed_output_dropout_07) %>%
layer_concatenate(name = "pay_mean07") %>%
layer_dense(units = 1, activation='linear',
weights = list(array(rep(0,neurons[3]+12),dim=c(neurons[3]+12,1)),array(starting_values[8,2],dim=c(1))))
payment_mean07 <- list(payment_mean07_pre2, AY_output_mean) %>%
layer_add %>%
layer_dense(units = 1, activation = 'linear', trainable = FALSE,
weights = list(array(1,dim=c(1,1)),array(0,dim=c(1))))
### Time 08
dropout_1_4_applied <- dropout_embed %>%
dropout_1_4(training = TRUE)
dropout_2_4_applied <- dropout_embed %>%
dropout_2_4(training = TRUE)
dropout_3_4_applied <- dropout_embed %>%
dropout_3_4(training = TRUE)
dropout_4_4_applied <- dropout_embed %>%
dropout_4_4(training = TRUE)
dropout_5_4_applied <- dropout_embed %>%
dropout_5_4(training = TRUE)
dropout_6_4_applied <- dropout_embed %>%
dropout_6_4(training = TRUE)
dropout_7_4_applied <- dropout_embed %>%
dropout_7_4(training = TRUE)
Pay01Info_embed_input_dropout_08 <- list(Pay01Info_embed_input, dropout_7_4_applied, Time_Known01) %>%
layer_multiply()
Pay01Info_embed_output_dropout_08 <- list(Pay01Info_embed_output, dropout_7_4_applied, Time_Known01) %>%
layer_multiply()
Pay02Info_embed_input_dropout_08 <- list(Pay02Info_embed_input, dropout_7_4_applied, dropout_6_4_applied, Time_Known02) %>%
layer_multiply()
Pay02Info_embed_output_dropout_08 <- list(Pay02Info_embed_output, dropout_7_4_applied, dropout_6_4_applied, Time_Known02) %>%
layer_multiply()
Pay03Info_embed_input_dropout_08 <- list(Pay03Info_embed_input, dropout_7_4_applied, dropout_6_4_applied, dropout_5_4_applied, Time_Known03) %>%
layer_multiply()
Pay03Info_embed_output_dropout_08 <- list(Pay03Info_embed_output, dropout_7_4_applied, dropout_6_4_applied, dropout_5_4_applied, Time_Known03) %>%
layer_multiply()
Pay04Info_embed_input_dropout_08 <- list(Pay04Info_embed_input, dropout_7_4_applied, dropout_6_4_applied, dropout_5_4_applied, dropout_4_4_applied, Time_Known04) %>%
layer_multiply()
Pay04Info_embed_output_dropout_08 <- list(Pay04Info_embed_output, dropout_7_4_applied, dropout_6_4_applied, dropout_5_4_applied, dropout_4_4_applied, Time_Known04) %>%
layer_multiply()
Pay05Info_embed_input_dropout_08 <- list(Pay05Info_embed_input, dropout_7_4_applied, dropout_6_4_applied, dropout_5_4_applied, dropout_4_4_applied, dropout_3_4_applied, Time_Known05) %>%
layer_multiply()
Pay05Info_embed_output_dropout_08 <- list(Pay05Info_embed_output, dropout_7_4_applied, dropout_6_4_applied, dropout_5_4_applied, dropout_4_4_applied, dropout_3_4_applied, Time_Known05) %>%
layer_multiply()
Pay06Info_embed_input_dropout_08 <- list(Pay06Info_embed_input, dropout_7_4_applied, dropout_6_4_applied, dropout_5_4_applied, dropout_4_4_applied, dropout_3_4_applied, dropout_2_4_applied, Time_Known06) %>%
layer_multiply()
Pay06Info_embed_output_dropout_08 <- list(Pay06Info_embed_output, dropout_7_4_applied, dropout_6_4_applied, dropout_5_4_applied, dropout_4_4_applied, dropout_3_4_applied, dropout_2_4_applied, Time_Known06) %>%
layer_multiply()
Pay07Info_embed_input_dropout_08 <- list(Pay07Info_embed_input, dropout_7_4_applied, dropout_6_4_applied, dropout_5_4_applied, dropout_4_4_applied, dropout_3_4_applied, dropout_2_4_applied, dropout_1_4_applied, Time_Known07) %>%
layer_multiply()
Pay07Info_embed_output_dropout_08 <- list(Pay07Info_embed_output, dropout_7_4_applied, dropout_6_4_applied, dropout_5_4_applied, dropout_4_4_applied, dropout_3_4_applied, dropout_2_4_applied, dropout_1_4_applied, Time_Known07) %>%
layer_multiply()
hidden_8_pre <- list(features_input, Pay00Info_embed_input, Pay01Info_embed_input_dropout_08, Pay02Info_embed_input_dropout_08, Pay03Info_embed_input_dropout_08, Pay04Info_embed_input_dropout_08, Pay05Info_embed_input_dropout_08, Pay06Info_embed_input_dropout_08, Pay07Info_embed_input_dropout_08) %>%
layer_concatenate() %>%
layer_dense(units=neurons[1], activation='linear')
hidden_8 <- list(hidden_8_pre, AY_embed_input_NN) %>%
layer_add %>%
layer_dense(units=neurons[1], activation='tanh', trainable = FALSE,
weights = list(diag(1,neurons[1]),array(0,dim=c(neurons[1])))) %>%
layer_dense(units=neurons[2], activation='tanh')
payment_indicator08_pre <- hidden_8 %>%
layer_dense(units=neurons[3], activation='tanh')
payment_indicator08_pre2 <- list(payment_indicator08_pre, features_output, Pay00Info_embed_output, Pay01Info_embed_output_dropout_08, Pay02Info_embed_output_dropout_08, Pay03Info_embed_output_dropout_08, Pay04Info_embed_output_dropout_08, Pay05Info_embed_output_dropout_08, Pay06Info_embed_output_dropout_08, Pay07Info_embed_output_dropout_08) %>%
layer_concatenate(name = "pay_ind08") %>%
layer_dense(units = 1, activation='linear',
weights = list(array(rep(0,neurons[3]+13),dim=c(neurons[3]+13,1)),array(log(starting_values[9,1]/(1-starting_values[9,1])),dim=c(1))))
payment_indicator08 <- list(payment_indicator08_pre2, AY_output_indicator) %>%
layer_add %>%
layer_dense(units = 1, activation = 'sigmoid', trainable = FALSE,
weights = list(array(1,dim=c(1,1)),array(0,dim=c(1))))
payment_mean08_pre <- hidden_8 %>%
layer_dense(units=neurons[3], activation='tanh')
payment_mean08_pre2 <- list(payment_mean08_pre, features_output, Pay00Info_embed_output, Pay01Info_embed_output_dropout_08, Pay02Info_embed_output_dropout_08, Pay03Info_embed_output_dropout_08, Pay04Info_embed_output_dropout_08, Pay05Info_embed_output_dropout_08, Pay06Info_embed_output_dropout_08, Pay07Info_embed_output_dropout_08) %>%
layer_concatenate(name = "pay_mean08") %>%
layer_dense(units = 1, activation='linear',
weights = list(array(rep(0,neurons[3]+13),dim=c(neurons[3]+13,1)),array(starting_values[9,2],dim=c(1))))
payment_mean08 <- list(payment_mean08_pre2, AY_output_mean) %>%
layer_add %>%
layer_dense(units = 1, activation = 'linear', trainable = FALSE,
weights = list(array(1,dim=c(1,1)),array(0,dim=c(1))))
### Time 09
dropout_1_3_applied <- dropout_embed %>%
dropout_1_3(training = TRUE)
dropout_2_3_applied <- dropout_embed %>%
dropout_2_3(training = TRUE)
dropout_3_3_applied <- dropout_embed %>%
dropout_3_3(training = TRUE)
dropout_4_3_applied <- dropout_embed %>%
dropout_4_3(training = TRUE)
dropout_5_3_applied <- dropout_embed %>%
dropout_5_3(training = TRUE)
dropout_6_3_applied <- dropout_embed %>%
dropout_6_3(training = TRUE)
dropout_7_3_applied <- dropout_embed %>%
dropout_7_3(training = TRUE)
dropout_8_3_applied <- dropout_embed %>%
dropout_8_3(training = TRUE)
Pay01Info_embed_input_dropout_09 <- list(Pay01Info_embed_input, dropout_8_3_applied, Time_Known01) %>%
layer_multiply()
Pay01Info_embed_output_dropout_09 <- list(Pay01Info_embed_output, dropout_8_3_applied, Time_Known01) %>%
layer_multiply()
Pay02Info_embed_input_dropout_09 <- list(Pay02Info_embed_input, dropout_8_3_applied, dropout_7_3_applied, Time_Known02) %>%
layer_multiply()
Pay02Info_embed_output_dropout_09 <- list(Pay02Info_embed_output, dropout_8_3_applied, dropout_7_3_applied, Time_Known02) %>%
layer_multiply()
Pay03Info_embed_input_dropout_09 <- list(Pay03Info_embed_input, dropout_8_3_applied, dropout_7_3_applied, dropout_6_3_applied, Time_Known03) %>%
layer_multiply()
Pay03Info_embed_output_dropout_09 <- list(Pay03Info_embed_output, dropout_8_3_applied, dropout_7_3_applied, dropout_6_3_applied, Time_Known03) %>%
layer_multiply()
Pay04Info_embed_input_dropout_09 <- list(Pay04Info_embed_input, dropout_8_3_applied, dropout_7_3_applied, dropout_6_3_applied, dropout_5_3_applied, Time_Known04) %>%
layer_multiply()
Pay04Info_embed_output_dropout_09 <- list(Pay04Info_embed_output, dropout_8_3_applied, dropout_7_3_applied, dropout_6_3_applied, dropout_5_3_applied, Time_Known04) %>%
layer_multiply()
Pay05Info_embed_input_dropout_09 <- list(Pay05Info_embed_input, dropout_8_3_applied, dropout_7_3_applied, dropout_6_3_applied, dropout_5_3_applied, dropout_4_3_applied, Time_Known05) %>%
layer_multiply()
Pay05Info_embed_output_dropout_09 <- list(Pay05Info_embed_output, dropout_8_3_applied, dropout_7_3_applied, dropout_6_3_applied, dropout_5_3_applied, dropout_4_3_applied, Time_Known05) %>%
layer_multiply()
Pay06Info_embed_input_dropout_09 <- list(Pay06Info_embed_input, dropout_8_3_applied, dropout_7_3_applied, dropout_6_3_applied, dropout_5_3_applied, dropout_4_3_applied, dropout_3_3_applied, Time_Known06) %>%
layer_multiply()
Pay06Info_embed_output_dropout_09 <- list(Pay06Info_embed_output, dropout_8_3_applied, dropout_7_3_applied, dropout_6_3_applied, dropout_5_3_applied, dropout_4_3_applied, dropout_3_3_applied, Time_Known06) %>%
layer_multiply()
Pay07Info_embed_input_dropout_09 <- list(Pay07Info_embed_input, dropout_8_3_applied, dropout_7_3_applied, dropout_6_3_applied, dropout_5_3_applied, dropout_4_3_applied, dropout_3_3_applied, dropout_2_3_applied, Time_Known07) %>%
layer_multiply()
Pay07Info_embed_output_dropout_09 <- list(Pay07Info_embed_output, dropout_8_3_applied, dropout_7_3_applied, dropout_6_3_applied, dropout_5_3_applied, dropout_4_3_applied, dropout_3_3_applied, dropout_2_3_applied, Time_Known07) %>%
layer_multiply()
Pay08Info_embed_input_dropout_09 <- list(Pay08Info_embed_input, dropout_8_3_applied, dropout_7_3_applied, dropout_6_3_applied, dropout_5_3_applied, dropout_4_3_applied, dropout_3_3_applied, dropout_2_3_applied, dropout_1_3_applied, Time_Known08) %>%
layer_multiply()
Pay08Info_embed_output_dropout_09 <- list(Pay08Info_embed_output, dropout_8_3_applied, dropout_7_3_applied, dropout_6_3_applied, dropout_5_3_applied, dropout_4_3_applied, dropout_3_3_applied, dropout_2_3_applied, dropout_1_3_applied, Time_Known08) %>%
layer_multiply()
hidden_9_pre <- list(features_input, Pay00Info_embed_input, Pay01Info_embed_input_dropout_09, Pay02Info_embed_input_dropout_09, Pay03Info_embed_input_dropout_09, Pay04Info_embed_input_dropout_09, Pay05Info_embed_input_dropout_09, Pay06Info_embed_input_dropout_09, Pay07Info_embed_input_dropout_09, Pay08Info_embed_input_dropout_09) %>%
layer_concatenate() %>%
layer_dense(units=neurons[1], activation='linear')
hidden_9 <- list(hidden_9_pre, AY_embed_input_NN) %>%
layer_add %>%
layer_dense(units=neurons[1], activation='tanh', trainable = FALSE,
weights = list(diag(1,neurons[1]),array(0,dim=c(neurons[1])))) %>%
layer_dense(units=neurons[2], activation='tanh')
payment_indicator09_pre <- hidden_9 %>%
layer_dense(units=neurons[3], activation='tanh')
payment_indicator09_pre2 <- list(payment_indicator09_pre, features_output, Pay00Info_embed_output, Pay01Info_embed_output_dropout_09, Pay02Info_embed_output_dropout_09, Pay03Info_embed_output_dropout_09, Pay04Info_embed_output_dropout_09, Pay05Info_embed_output_dropout_09, Pay06Info_embed_output_dropout_09, Pay07Info_embed_output_dropout_09, Pay08Info_embed_output_dropout_09) %>%
layer_concatenate(name = "pay_ind09") %>%
layer_dense(units = 1, activation='linear',
weights = list(array(rep(0,neurons[3]+14),dim=c(neurons[3]+14,1)),array(log(starting_values[10,1]/(1-starting_values[10,1])),dim=c(1))))
payment_indicator09 <- list(payment_indicator09_pre2, AY_output_indicator) %>%
layer_add %>%
layer_dense(units = 1, activation = 'sigmoid', trainable = FALSE,
weights = list(array(1,dim=c(1,1)),array(0,dim=c(1))))
payment_mean09_pre <- hidden_9 %>%
layer_dense(units=neurons[3], activation='tanh')
payment_mean09_pre2 <- list(payment_mean09_pre, features_output, Pay00Info_embed_output, Pay01Info_embed_output_dropout_09, Pay02Info_embed_output_dropout_09, Pay03Info_embed_output_dropout_09, Pay04Info_embed_output_dropout_09, Pay05Info_embed_output_dropout_09, Pay06Info_embed_output_dropout_09, Pay07Info_embed_output_dropout_09, Pay08Info_embed_output_dropout_09) %>%
layer_concatenate(name = "pay_mean09") %>%
layer_dense(units = 1, activation='linear',
weights = list(array(rep(0,neurons[3]+14),dim=c(neurons[3]+14,1)),array(starting_values[10,2],dim=c(1))))
payment_mean09 <- list(payment_mean09_pre2, AY_output_mean) %>%
layer_add %>%
layer_dense(units = 1, activation = 'linear', trainable = FALSE,
weights = list(array(1,dim=c(1,1)),array(0,dim=c(1))))
### Time 10
dropout_1_2_applied <- dropout_embed %>%
dropout_1_2(training = TRUE)
dropout_2_2_applied <- dropout_embed %>%
dropout_2_2(training = TRUE)
dropout_3_2_applied <- dropout_embed %>%
dropout_3_2(training = TRUE)
dropout_4_2_applied <- dropout_embed %>%
dropout_4_2(training = TRUE)
dropout_5_2_applied <- dropout_embed %>%
dropout_5_2(training = TRUE)
dropout_6_2_applied <- dropout_embed %>%
dropout_6_2(training = TRUE)
dropout_7_2_applied <- dropout_embed %>%
dropout_7_2(training = TRUE)
dropout_8_2_applied <- dropout_embed %>%
dropout_8_2(training = TRUE)
dropout_9_2_applied <- dropout_embed %>%
dropout_9_2(training = TRUE)
Pay01Info_embed_input_dropout_10 <- list(Pay01Info_embed_input, dropout_9_2_applied, Time_Known01) %>%
layer_multiply()
Pay01Info_embed_output_dropout_10 <- list(Pay01Info_embed_output, dropout_9_2_applied, Time_Known01) %>%
layer_multiply()
Pay02Info_embed_input_dropout_10 <- list(Pay02Info_embed_input, dropout_9_2_applied, dropout_8_2_applied, Time_Known02) %>%
layer_multiply()
Pay02Info_embed_output_dropout_10 <- list(Pay02Info_embed_output, dropout_9_2_applied, dropout_8_2_applied, Time_Known02) %>%
layer_multiply()
Pay03Info_embed_input_dropout_10 <- list(Pay03Info_embed_input, dropout_9_2_applied, dropout_8_2_applied, dropout_7_2_applied, Time_Known03) %>%
layer_multiply()
Pay03Info_embed_output_dropout_10 <- list(Pay03Info_embed_output, dropout_9_2_applied, dropout_8_2_applied, dropout_7_2_applied, Time_Known03) %>%
layer_multiply()
Pay04Info_embed_input_dropout_10 <- list(Pay04Info_embed_input, dropout_9_2_applied, dropout_8_2_applied, dropout_7_2_applied, dropout_6_2_applied, Time_Known04) %>%
layer_multiply()
Pay04Info_embed_output_dropout_10 <- list(Pay04Info_embed_output, dropout_9_2_applied, dropout_8_2_applied, dropout_7_2_applied, dropout_6_2_applied, Time_Known04) %>%
layer_multiply()
Pay05Info_embed_input_dropout_10 <- list(Pay05Info_embed_input, dropout_9_2_applied, dropout_8_2_applied, dropout_7_2_applied, dropout_6_2_applied, dropout_5_2_applied, Time_Known05) %>%
layer_multiply()
Pay05Info_embed_output_dropout_10 <- list(Pay05Info_embed_output, dropout_9_2_applied, dropout_8_2_applied, dropout_7_2_applied, dropout_6_2_applied, dropout_5_2_applied, Time_Known05) %>%
layer_multiply()
Pay06Info_embed_input_dropout_10 <- list(Pay06Info_embed_input, dropout_9_2_applied, dropout_8_2_applied, dropout_7_2_applied, dropout_6_2_applied, dropout_5_2_applied, dropout_4_2_applied, Time_Known06) %>%
layer_multiply()
Pay06Info_embed_output_dropout_10 <- list(Pay06Info_embed_output, dropout_9_2_applied, dropout_8_2_applied, dropout_7_2_applied, dropout_6_2_applied, dropout_5_2_applied, dropout_4_2_applied, Time_Known06) %>%
layer_multiply()
Pay07Info_embed_input_dropout_10 <- list(Pay07Info_embed_input, dropout_9_2_applied, dropout_8_2_applied, dropout_7_2_applied, dropout_6_2_applied, dropout_5_2_applied, dropout_4_2_applied, dropout_3_2_applied, Time_Known07) %>%
layer_multiply()
Pay07Info_embed_output_dropout_10 <- list(Pay07Info_embed_output, dropout_9_2_applied, dropout_8_2_applied, dropout_7_2_applied, dropout_6_2_applied, dropout_5_2_applied, dropout_4_2_applied, dropout_3_2_applied, Time_Known07) %>%
layer_multiply()
Pay08Info_embed_input_dropout_10 <- list(Pay08Info_embed_input, dropout_9_2_applied, dropout_8_2_applied, dropout_7_2_applied, dropout_6_2_applied, dropout_5_2_applied, dropout_4_2_applied, dropout_3_2_applied, dropout_2_2_applied, Time_Known08) %>%
layer_multiply()
Pay08Info_embed_output_dropout_10 <- list(Pay08Info_embed_output, dropout_9_2_applied, dropout_8_2_applied, dropout_7_2_applied, dropout_6_2_applied, dropout_5_2_applied, dropout_4_2_applied, dropout_3_2_applied, dropout_2_2_applied, Time_Known08) %>%
layer_multiply()
Pay09Info_embed_input_dropout_10 <- list(Pay09Info_embed_input, dropout_9_2_applied, dropout_8_2_applied, dropout_7_2_applied, dropout_6_2_applied, dropout_5_2_applied, dropout_4_2_applied, dropout_3_2_applied, dropout_2_2_applied, dropout_1_2_applied, Time_Known09) %>%
layer_multiply()
Pay09Info_embed_output_dropout_10 <- list(Pay09Info_embed_output, dropout_9_2_applied, dropout_8_2_applied, dropout_7_2_applied, dropout_6_2_applied, dropout_5_2_applied, dropout_4_2_applied, dropout_3_2_applied, dropout_2_2_applied, dropout_1_2_applied, Time_Known09) %>%
layer_multiply()
hidden_10_pre <- list(features_input, Pay00Info_embed_input, Pay01Info_embed_input_dropout_10, Pay02Info_embed_input_dropout_10, Pay03Info_embed_input_dropout_10, Pay04Info_embed_input_dropout_10, Pay05Info_embed_input_dropout_10, Pay06Info_embed_input_dropout_10, Pay07Info_embed_input_dropout_10, Pay08Info_embed_input_dropout_10, Pay09Info_embed_input_dropout_10) %>%
layer_concatenate() %>%
layer_dense(units=neurons[1], activation='linear')
hidden_10 <- list(hidden_10_pre, AY_embed_input_NN) %>%
layer_add %>%
layer_dense(units=neurons[1], activation='tanh', trainable = FALSE,
weights = list(diag(1,neurons[1]),array(0,dim=c(neurons[1])))) %>%
layer_dense(units=neurons[2], activation='tanh')
payment_indicator10_pre <- hidden_10 %>%
layer_dense(units=neurons[3], activation='tanh')
payment_indicator10_pre2 <- list(payment_indicator10_pre, features_output, Pay00Info_embed_output, Pay01Info_embed_output_dropout_10, Pay02Info_embed_output_dropout_10, Pay03Info_embed_output_dropout_10, Pay04Info_embed_output_dropout_10, Pay05Info_embed_output_dropout_10, Pay06Info_embed_output_dropout_10, Pay07Info_embed_output_dropout_10, Pay08Info_embed_output_dropout_10, Pay09Info_embed_output_dropout_10) %>%
layer_concatenate(name = "pay_ind10") %>%
layer_dense(units = 1, activation='linear',
weights = list(array(rep(0,neurons[3]+15),dim=c(neurons[3]+15,1)),array(log(starting_values[11,1]/(1-starting_values[11,1])),dim=c(1))))
payment_indicator10 <- list(payment_indicator10_pre2, AY_output_indicator) %>%
layer_add %>%
layer_dense(units = 1, activation = 'sigmoid', trainable = FALSE,
weights = list(array(1,dim=c(1,1)),array(0,dim=c(1))))
payment_mean10_pre <- hidden_10 %>%
layer_dense(units=neurons[3], activation='tanh')
payment_mean10_pre2 <- list(payment_mean10_pre, features_output, Pay00Info_embed_output, Pay01Info_embed_output_dropout_10, Pay02Info_embed_output_dropout_10, Pay03Info_embed_output_dropout_10, Pay04Info_embed_output_dropout_10, Pay05Info_embed_output_dropout_10, Pay06Info_embed_output_dropout_10, Pay07Info_embed_output_dropout_10, Pay08Info_embed_output_dropout_10, Pay09Info_embed_output_dropout_10) %>%
layer_concatenate(name = "pay_mean10") %>%
layer_dense(units = 1, activation='linear',
weights = list(array(rep(0,neurons[3]+15),dim=c(neurons[3]+15,1)),array(starting_values[11,2],dim=c(1))))
payment_mean10 <- list(payment_mean10_pre2, AY_output_mean) %>%
layer_add %>%
layer_dense(units = 1, activation = 'linear', trainable = FALSE,
weights = list(array(1,dim=c(1,1)),array(0,dim=c(1))))
### Time 11
dropout_1_1_applied <- dropout_embed %>%
dropout_1_1(training = TRUE)
dropout_2_1_applied <- dropout_embed %>%
dropout_2_1(training = TRUE)
dropout_3_1_applied <- dropout_embed %>%
dropout_3_1(training = TRUE)
dropout_4_1_applied <- dropout_embed %>%
dropout_4_1(training = TRUE)
dropout_5_1_applied <- dropout_embed %>%
dropout_5_1(training = TRUE)
dropout_6_1_applied <- dropout_embed %>%
dropout_6_1(training = TRUE)
dropout_7_1_applied <- dropout_embed %>%
dropout_7_1(training = TRUE)
dropout_8_1_applied <- dropout_embed %>%
dropout_8_1(training = TRUE)
dropout_9_1_applied <- dropout_embed %>%
dropout_9_1(training = TRUE)
dropout_10_1_applied <- dropout_embed %>%
dropout_10_1(training = TRUE)
Pay01Info_embed_input_dropout_11 <- list(Pay01Info_embed_input, dropout_10_1_applied, Time_Known01) %>%
layer_multiply()
Pay01Info_embed_output_dropout_11 <- list(Pay01Info_embed_output, dropout_10_1_applied, Time_Known01) %>%
layer_multiply()
Pay02Info_embed_input_dropout_11 <- list(Pay02Info_embed_input, dropout_10_1_applied, dropout_9_1_applied, Time_Known02) %>%
layer_multiply()
Pay02Info_embed_output_dropout_11 <- list(Pay02Info_embed_output, dropout_10_1_applied, dropout_9_1_applied, Time_Known02) %>%
layer_multiply()
Pay03Info_embed_input_dropout_11 <- list(Pay03Info_embed_input, dropout_10_1_applied, dropout_9_1_applied, dropout_8_1_applied, Time_Known03) %>%
layer_multiply()
Pay03Info_embed_output_dropout_11 <- list(Pay03Info_embed_output, dropout_10_1_applied, dropout_9_1_applied, dropout_8_1_applied, Time_Known03) %>%
layer_multiply()
Pay04Info_embed_input_dropout_11 <- list(Pay04Info_embed_input, dropout_10_1_applied, dropout_9_1_applied, dropout_8_1_applied, dropout_7_1_applied, Time_Known04) %>%
layer_multiply()
Pay04Info_embed_output_dropout_11 <- list(Pay04Info_embed_output, dropout_10_1_applied, dropout_9_1_applied, dropout_8_1_applied, dropout_7_1_applied, Time_Known04) %>%
layer_multiply()
Pay05Info_embed_input_dropout_11 <- list(Pay05Info_embed_input, dropout_10_1_applied, dropout_9_1_applied, dropout_8_1_applied, dropout_7_1_applied, dropout_6_1_applied, Time_Known05) %>%
layer_multiply()
Pay05Info_embed_output_dropout_11 <- list(Pay05Info_embed_output, dropout_10_1_applied, dropout_9_1_applied, dropout_8_1_applied, dropout_7_1_applied, dropout_6_1_applied, Time_Known05) %>%
layer_multiply()
Pay06Info_embed_input_dropout_11 <- list(Pay06Info_embed_input, dropout_10_1_applied, dropout_9_1_applied, dropout_8_1_applied, dropout_7_1_applied, dropout_6_1_applied, dropout_5_1_applied, Time_Known06) %>%
layer_multiply()
Pay06Info_embed_output_dropout_11 <- list(Pay06Info_embed_output, dropout_10_1_applied, dropout_9_1_applied, dropout_8_1_applied, dropout_7_1_applied, dropout_6_1_applied, dropout_5_1_applied, Time_Known06) %>%
layer_multiply()
Pay07Info_embed_input_dropout_11 <- list(Pay07Info_embed_input, dropout_10_1_applied, dropout_9_1_applied, dropout_8_1_applied, dropout_7_1_applied, dropout_6_1_applied, dropout_5_1_applied, dropout_4_1_applied, Time_Known07) %>%
layer_multiply()
Pay07Info_embed_output_dropout_11 <- list(Pay07Info_embed_output, dropout_10_1_applied, dropout_9_1_applied, dropout_8_1_applied, dropout_7_1_applied, dropout_6_1_applied, dropout_5_1_applied, dropout_4_1_applied, Time_Known07) %>%
layer_multiply()
Pay08Info_embed_input_dropout_11 <- list(Pay08Info_embed_input, dropout_10_1_applied, dropout_9_1_applied, dropout_8_1_applied, dropout_7_1_applied, dropout_6_1_applied, dropout_5_1_applied, dropout_4_1_applied, dropout_3_1_applied, Time_Known08) %>%
layer_multiply()
Pay08Info_embed_output_dropout_11 <- list(Pay08Info_embed_output, dropout_10_1_applied, dropout_9_1_applied, dropout_8_1_applied, dropout_7_1_applied, dropout_6_1_applied, dropout_5_1_applied, dropout_4_1_applied, dropout_3_1_applied, Time_Known08) %>%
layer_multiply()
Pay09Info_embed_input_dropout_11 <- list(Pay09Info_embed_input, dropout_10_1_applied, dropout_9_1_applied, dropout_8_1_applied, dropout_7_1_applied, dropout_6_1_applied, dropout_5_1_applied, dropout_4_1_applied, dropout_3_1_applied, dropout_2_1_applied, Time_Known09) %>%
layer_multiply()
Pay09Info_embed_output_dropout_11 <- list(Pay09Info_embed_output, dropout_10_1_applied, dropout_9_1_applied, dropout_8_1_applied, dropout_7_1_applied, dropout_6_1_applied, dropout_5_1_applied, dropout_4_1_applied, dropout_3_1_applied, dropout_2_1_applied, Time_Known09) %>%
layer_multiply()
Pay10Info_embed_input_dropout_11 <- list(Pay10Info_embed_input, dropout_10_1_applied, dropout_9_1_applied, dropout_8_1_applied, dropout_7_1_applied, dropout_6_1_applied, dropout_5_1_applied, dropout_4_1_applied, dropout_3_1_applied, dropout_2_1_applied, dropout_1_1_applied, Time_Known10) %>%
layer_multiply()
Pay10Info_embed_output_dropout_11 <- list(Pay10Info_embed_output, dropout_10_1_applied, dropout_9_1_applied, dropout_8_1_applied, dropout_7_1_applied, dropout_6_1_applied, dropout_5_1_applied, dropout_4_1_applied, dropout_3_1_applied, dropout_2_1_applied, dropout_1_1_applied, Time_Known10) %>%
layer_multiply()
hidden_11_pre <- list(features_input, Pay00Info_embed_input, Pay01Info_embed_input_dropout_11, Pay02Info_embed_input_dropout_11, Pay03Info_embed_input_dropout_11, Pay04Info_embed_input_dropout_11, Pay05Info_embed_input_dropout_11, Pay06Info_embed_input_dropout_11, Pay07Info_embed_input_dropout_11, Pay08Info_embed_input_dropout_11, Pay09Info_embed_input_dropout_11, Pay10Info_embed_input_dropout_11) %>%
layer_concatenate() %>%
layer_dense(units=neurons[1], activation='linear')
hidden_11 <- list(hidden_11_pre, AY_embed_input_NN) %>%
layer_add %>%
layer_dense(units=neurons[1], activation='tanh', trainable = FALSE,
weights = list(diag(1,neurons[1]),array(0,dim=c(neurons[1])))) %>%
layer_dense(units=neurons[2], activation='tanh')
payment_indicator11_pre <- hidden_11 %>%
layer_dense(units=neurons[3], activation='tanh')
payment_indicator11_pre2 <- list(payment_indicator11_pre, features_output, Pay00Info_embed_output, Pay01Info_embed_output_dropout_11, Pay02Info_embed_output_dropout_11, Pay03Info_embed_output_dropout_11, Pay04Info_embed_output_dropout_11, Pay05Info_embed_output_dropout_11, Pay06Info_embed_output_dropout_11, Pay07Info_embed_output_dropout_11, Pay08Info_embed_output_dropout_11, Pay09Info_embed_output_dropout_11, Pay10Info_embed_output_dropout_11) %>%
layer_concatenate(name = "pay_ind11") %>%
layer_dense(units = 1, activation='linear',
weights = list(array(rep(0,neurons[3]+16),dim=c(neurons[3]+16,1)),array(log(starting_values[12,1]/(1-starting_values[12,1])),dim=c(1))))
payment_indicator11 <- list(payment_indicator11_pre2, AY_output_indicator) %>%
layer_add %>%
layer_dense(units = 1, activation = 'sigmoid', trainable = FALSE,
weights = list(array(1,dim=c(1,1)),array(0,dim=c(1))))
payment_mean11_pre <- hidden_11 %>%
layer_dense(units=neurons[3], activation='tanh')
payment_mean11_pre2 <- list(payment_mean11_pre, features_output, Pay00Info_embed_output, Pay01Info_embed_output_dropout_11, Pay02Info_embed_output_dropout_11, Pay03Info_embed_output_dropout_11, Pay04Info_embed_output_dropout_11, Pay05Info_embed_output_dropout_11, Pay06Info_embed_output_dropout_11, Pay07Info_embed_output_dropout_11, Pay08Info_embed_output_dropout_11, Pay09Info_embed_output_dropout_11, Pay10Info_embed_output_dropout_11) %>%
layer_concatenate(name = "pay_mean11") %>%
layer_dense(units = 1, activation='linear',
weights = list(array(rep(0,neurons[3]+16),dim=c(neurons[3]+16,1)),array(starting_values[12,2],dim=c(1))))
payment_mean11 <- list(payment_mean11_pre2, AY_output_mean) %>%
layer_add %>%
layer_dense(units = 1, activation = 'linear', trainable = FALSE,
weights = list(array(1,dim=c(1,1)),array(0,dim=c(1))))
### Multiply the outputs with the Time_Predict indicators (0/1)
### Time 00
payment_indicator00_output <- list(payment_indicator00, Time_Predict_Indicator00) %>%
layer_multiply(name = 'payment_indicator00_output')
payment_mean00_output <- list(payment_mean00, Time_Predict_Payment00) %>%
layer_multiply(name = 'payment_mean00_output')
### Time 01
payment_indicator01_output <- list(payment_indicator01, Time_Predict_Indicator01) %>%
layer_multiply(name = 'payment_indicator01_output')
payment_mean01_output <- list(payment_mean01, Time_Predict_Payment01) %>%
layer_multiply(name = 'payment_mean01_output')
### Time 02
payment_indicator02_output <- list(payment_indicator02, Time_Predict_Indicator02) %>%
layer_multiply(name = 'payment_indicator02_output')
payment_mean02_output <- list(payment_mean02, Time_Predict_Payment02) %>%
layer_multiply(name = 'payment_mean02_output')
### Time 03
payment_indicator03_output <- list(payment_indicator03, Time_Predict_Indicator03) %>%
layer_multiply(name = 'payment_indicator03_output')
payment_mean03_output <- list(payment_mean03, Time_Predict_Payment03) %>%
layer_multiply(name = 'payment_mean03_output')
### Time 04
payment_indicator04_output <- list(payment_indicator04, Time_Predict_Indicator04) %>%
layer_multiply(name = 'payment_indicator04_output')
payment_mean04_output <- list(payment_mean04, Time_Predict_Payment04) %>%
layer_multiply(name = 'payment_mean04_output')
### Time 05
payment_indicator05_output <- list(payment_indicator05, Time_Predict_Indicator05) %>%
layer_multiply(name = 'payment_indicator05_output')
payment_mean05_output <- list(payment_mean05, Time_Predict_Payment05) %>%
layer_multiply(name = 'payment_mean05_output')
### Time 06
payment_indicator06_output <- list(payment_indicator06, Time_Predict_Indicator06) %>%
layer_multiply(name = 'payment_indicator06_output')
payment_mean06_output <- list(payment_mean06, Time_Predict_Payment06) %>%
layer_multiply(name = 'payment_mean06_output')
### Time 07
payment_indicator07_output <- list(payment_indicator07, Time_Predict_Indicator07) %>%
layer_multiply(name = 'payment_indicator07_output')
payment_mean07_output <- list(payment_mean07, Time_Predict_Payment07) %>%
layer_multiply(name = 'payment_mean07_output')
### Time 08
payment_indicator08_output <- list(payment_indicator08, Time_Predict_Indicator08) %>%
layer_multiply(name = 'payment_indicator08_output')
payment_mean08_output <- list(payment_mean08, Time_Predict_Payment08) %>%
layer_multiply(name = 'payment_mean08_output')
### Time 09
payment_indicator09_output <- list(payment_indicator09, Time_Predict_Indicator09) %>%
layer_multiply(name = 'payment_indicator09_output')
payment_mean09_output <- list(payment_mean09, Time_Predict_Payment09) %>%
layer_multiply(name = 'payment_mean09_output')
### Time 10
payment_indicator10_output <- list(payment_indicator10, Time_Predict_Indicator10) %>%
layer_multiply(name = 'payment_indicator10_output')
payment_mean10_output <- list(payment_mean10, Time_Predict_Payment10) %>%
layer_multiply(name = 'payment_mean10_output')
### Time 11
payment_indicator11_output <- list(payment_indicator11, Time_Predict_Indicator11) %>%
layer_multiply(name = 'payment_indicator11_output')
payment_mean11_output <- list(payment_mean11, Time_Predict_Payment11) %>%
layer_multiply(name = 'payment_mean11_output')
### Keras model
model <- keras_model(inputs = c(dropout, cc, AY, AQ, age, inj_part, RepDel,
Time_Known01, Time_Known02, Time_Known03, Time_Known04, Time_Known05, Time_Known06,
Time_Known07, Time_Known08, Time_Known09, Time_Known10, Time_Known11,
Pay00Info, Pay01Info, Pay02Info, Pay03Info, Pay04Info, Pay05Info,
Pay06Info, Pay07Info, Pay08Info, Pay09Info, Pay10Info,
Time_Predict_Indicator00, Time_Predict_Indicator01, Time_Predict_Indicator02, Time_Predict_Indicator03, Time_Predict_Indicator04, Time_Predict_Indicator05,
Time_Predict_Indicator06, Time_Predict_Indicator07, Time_Predict_Indicator08, Time_Predict_Indicator09, Time_Predict_Indicator10, Time_Predict_Indicator11,
Time_Predict_Payment00, Time_Predict_Payment01, Time_Predict_Payment02, Time_Predict_Payment03, Time_Predict_Payment04, Time_Predict_Payment05,
Time_Predict_Payment06, Time_Predict_Payment07, Time_Predict_Payment08, Time_Predict_Payment09, Time_Predict_Payment10, Time_Predict_Payment11),
outputs = c(payment_indicator00_output, payment_mean00_output, payment_indicator01_output, payment_mean01_output,
payment_indicator02_output, payment_mean02_output, payment_indicator03_output, payment_mean03_output,
payment_indicator04_output, payment_mean04_output, payment_indicator05_output, payment_mean05_output,
payment_indicator06_output, payment_mean06_output, payment_indicator07_output, payment_mean07_output,
payment_indicator08_output, payment_mean08_output, payment_indicator09_output, payment_mean09_output,
payment_indicator10_output, payment_mean10_output, payment_indicator11_output, payment_mean11_output))
model %>% compile(optimizer = optimizer_nadam(),
loss = list(payment_indicator00_output = 'binary_crossentropy', payment_mean00_output = 'mse',
payment_indicator01_output = 'binary_crossentropy', payment_mean01_output = 'mse',
payment_indicator02_output = 'binary_crossentropy', payment_mean02_output = 'mse',
payment_indicator03_output = 'binary_crossentropy', payment_mean03_output = 'mse',
payment_indicator04_output = 'binary_crossentropy', payment_mean04_output = 'mse',
payment_indicator05_output = 'binary_crossentropy', payment_mean05_output = 'mse',
payment_indicator06_output = 'binary_crossentropy', payment_mean06_output = 'mse',
payment_indicator07_output = 'binary_crossentropy', payment_mean07_output = 'mse',
payment_indicator08_output = 'binary_crossentropy', payment_mean08_output = 'mse',
payment_indicator09_output = 'binary_crossentropy', payment_mean09_output = 'mse',
payment_indicator10_output = 'binary_crossentropy', payment_mean10_output = 'mse',
payment_indicator11_output = 'binary_crossentropy', payment_mean11_output = 'mse'),
loss_weights = list(payment_indicator00_output = network_weights[1,1], payment_mean00_output = network_weights[1,2],
payment_indicator01_output = network_weights[2,1], payment_mean01_output = network_weights[2,2],
payment_indicator02_output = network_weights[3,1], payment_mean02_output = network_weights[3,2],
payment_indicator03_output = network_weights[4,1], payment_mean03_output = network_weights[4,2],
payment_indicator04_output = network_weights[5,1], payment_mean04_output = network_weights[5,2],
payment_indicator05_output = network_weights[6,1], payment_mean05_output = network_weights[6,2],
payment_indicator06_output = network_weights[7,1], payment_mean06_output = network_weights[7,2],
payment_indicator07_output = network_weights[8,1], payment_mean07_output = network_weights[8,2],
payment_indicator08_output = network_weights[9,1], payment_mean08_output = network_weights[9,2],
payment_indicator09_output = network_weights[10,1], payment_mean09_output = network_weights[10,2],
payment_indicator10_output = network_weights[11,1], payment_mean10_output = network_weights[11,2],
payment_indicator11_output = network_weights[12,1], payment_mean11_output = network_weights[12,2]))
model
} After this code, I ran the following: library(keras)
library(plyr)
source(file="./NeuralNetworkModels.R")
#########################
### Line of business ###
#########################
LoB <- 1
######################
### Load the data ###
######################
data <- read.table("./Data/data.txt", header=TRUE, sep=";")
data <- data[data$LoB==LoB,]
data$LoB <- as.factor(data$LoB)
data$cc <- as.factor(data$cc)
data$inj_part <- as.factor(data$inj_part)
str(data)
########################
### Data preparation ###
########################
### Features
data$RepDelnew <- pmin(2,data$RepDel) ### cap reporting delay at 2
l0 <- ncol(data)
data$LoBx <- as.integer(as.numeric(data$LoB)-1) ### LoB categorical (we will only use that as artificial embedding for dropout)
cc_transform <- cbind(as.integer(levels(data$cc)),0:(length(levels(data$cc))-1))
data$ccx <- cc_transform[data$cc,2] ### cc categorical
data$AYx <- as.integer(data$AY-1994) ### AY categorical
data$AQx <- as.integer(data$AQ-1) ### AQ categorical
data$agex <- as.integer(levels(cut(data$age, c(14,20,25,30,35,40,45,50,55,60,65,70), right=TRUE, labels=c(0:10))))[cut(data$age, c(14,20,25,30,35,40,45,50,55,60,65,70), right=TRUE, labels=c(0:10))] ### age categorical in 5 years age buckets
inj_part_transform <- cbind(as.integer(levels(data$inj_part)),0:(length(levels(data$inj_part))-1))
data$inj_partx <- inj_part_transform[data$inj_part,2] ### inj_part categorical
data$RepDelx <- as.integer(data$RepDelnew) ### RepDelnew categorical
### Time known at the end of 2005 (time points for which we have the payment information at the end of year 2005)
l1 <- ncol(data)
data[,c("Time_Known00", "Time_Known01", "Time_Known02", "Time_Known03", "Time_Known04", "Time_Known05", "Time_Known06", "Time_Known07", "Time_Known08", "Time_Known09", "Time_Known10", "Time_Known11")] <- 0
for (i in 1:12){
data[data$AY + data$RepDel <= 2006-i,l1+i] <- 1
}
### Past payment info (feature information about past payments, the information at time 11 is never used as a feature and thus neglected)
l2 <- ncol(data)
data[,c("Pay00Info", "Pay01Info", "Pay02Info", "Pay03Info", "Pay04Info", "Pay05Info", "Pay06Info", "Pay07Info", "Pay08Info", "Pay09Info", "Pay10Info")] <- as.integer(0)
for (i in 1:11){
data[,l2+i][data[,l1+i]==1] <- as.integer(levels(cut(data[,8+i][data[,l1+i]==1], c(-Inf,-1,0,5000,20000,100000,Inf), right=TRUE, labels=c(1,0,2,3,4,5))))[cut(data[,8+i][data[,l1+i]==1], c(-Inf,-1,0,5000,20000,100000,Inf), right=TRUE, labels=c(1,0,2,3,4,5))]
}
### Payment indicator (response variable indicating whether we have a payment or not)
l3 <- ncol(data)
data[,c("PayInd00", "PayInd01", "PayInd02", "PayInd03", "PayInd04", "PayInd05", "PayInd06", "PayInd07", "PayInd08", "PayInd09", "PayInd10", "PayInd11")] <- as.integer(0)
for (i in 1:12){
data[,l3+i][data[,l1+i]==1] <- as.integer(data[,8+i][data[,l1+i]==1]>0)
}
### Logarithmic payment (response variable indicating the log size of the payment if there is a payment)
l4 <- ncol(data)
data[,c("LogPay00", "LogPay01", "LogPay02", "LogPay03", "LogPay04", "LogPay05", "LogPay06", "LogPay07", "LogPay08", "LogPay09", "LogPay10", "LogPay11")] <- 0
for (i in 1:12){
data[,l4+i][data[,l1+i]==1 & data[,8+i]>0] <- log(data[,8+i][data[,l1+i]==1 & data[,8+i]>0])
}
### Time points for which we would like to estimate the payment probability (during training these are equal to the time points known)
l5 <- ncol(data)
data[,c("Time_Predict_Indicator00", "Time_Predict_Indicator01", "Time_Predict_Indicator02", "Time_Predict_Indicator03", "Time_Predict_Indicator04", "Time_Predict_Indicator05", "Time_Predict_Indicator06", "Time_Predict_Indicator07", "Time_Predict_Indicator08", "Time_Predict_Indicator09", "Time_Predict_Indicator10", "Time_Predict_Indicator11")] <- 0
l6 <- ncol(data)
data[,(l5+1):l6] <- data[,(l1+1):(l1+12)]
### Time points for which we would like to estimate the payment size (during training these are equal to the time points where we have a payment)
data[,c("Time_Predict_Payment00", "Time_Predict_Payment01", "Time_Predict_Payment02", "Time_Predict_Payment03", "Time_Predict_Payment04", "Time_Predict_Payment05", "Time_Predict_Payment06", "Time_Predict_Payment07", "Time_Predict_Payment08", "Time_Predict_Payment09", "Time_Predict_Payment10", "Time_Predict_Payment11")] <- 0
l7 <- ncol(data)
data[,(l6+1):ncol(data)] <- data[,(l3+1):(l3+12)]
################
### Features ###
################
### Complete data set
features_all <- data.matrix(data[,c((l0+1):l1,(l1+2):l3,(l5+1):l7)]) ### l1+1 is Time_Known00, which is always equal to 1 and therefore omitted
features_all_input <- list(dropout = features_all[,1], cc = features_all[,2], AY = features_all[,3], AQ = features_all[,4], age = features_all[,5], inj_part = features_all[,6], RepDel = features_all[,7],
Time_Known01 = features_all[,8], Time_Known02 = features_all[,9], Time_Known03 = features_all[,10], Time_Known04 = features_all[,11], Time_Known05 = features_all[,12],
Time_Known06 = features_all[,13], Time_Known07 = features_all[,14], Time_Known08 = features_all[,15], Time_Known09 = features_all[,16], Time_Known10 = features_all[,17], Time_Known11 = features_all[,18],
Pay00Info = features_all[,19], Pay01Info = features_all[,20], Pay02Info = features_all[,21], Pay03Info = features_all[,22], Pay04Info = features_all[,23], Pay05Info = features_all[,24],
Pay06Info = features_all[,25], Pay07Info = features_all[,26], Pay08Info = features_all[,27], Pay09Info = features_all[,28], Pay10Info = features_all[,29],
Time_Predict_Indicator00 = features_all[,30], Time_Predict_Indicator01 = features_all[,31], Time_Predict_Indicator02 = features_all[,32], Time_Predict_Indicator03 = features_all[,33], Time_Predict_Indicator04 = features_all[,34], Time_Predict_Indicator05 = features_all[,35],
Time_Predict_Indicator06 = features_all[,36], Time_Predict_Indicator07 = features_all[,37], Time_Predict_Indicator08 = features_all[,38], Time_Predict_Indicator09 = features_all[,39], Time_Predict_Indicator10 = features_all[,40], Time_Predict_Indicator11 = features_all[,41],
Time_Predict_Payment00 = features_all[,42], Time_Predict_Payment01 = features_all[,43], Time_Predict_Payment02 = features_all[,44], Time_Predict_Payment03 = features_all[,45], Time_Predict_Payment04 = features_all[,46], Time_Predict_Payment05 = features_all[,47],
Time_Predict_Payment06 = features_all[,48], Time_Predict_Payment07 = features_all[,49], Time_Predict_Payment08 = features_all[,50], Time_Predict_Payment09 = features_all[,51], Time_Predict_Payment10 = features_all[,52], Time_Predict_Payment11 = features_all[,53])
#################
### Responses ###
#################
### Complete data set
responses_all <- data.matrix(data[,c((l3+1):l5)])
responses_all_input <- list(payment_indicator00_output = responses_all[,1], payment_mean00_output = responses_all[,13],
payment_indicator01_output = responses_all[,2], payment_mean01_output = responses_all[,14],
payment_indicator02_output = responses_all[,3], payment_mean02_output = responses_all[,15],
payment_indicator03_output = responses_all[,4], payment_mean03_output = responses_all[,16],
payment_indicator04_output = responses_all[,5], payment_mean04_output = responses_all[,17],
payment_indicator05_output = responses_all[,6], payment_mean05_output = responses_all[,18],
payment_indicator06_output = responses_all[,7], payment_mean06_output = responses_all[,19],
payment_indicator07_output = responses_all[,8], payment_mean07_output = responses_all[,20],
payment_indicator08_output = responses_all[,9], payment_mean08_output = responses_all[,21],
payment_indicator09_output = responses_all[,10], payment_mean09_output = responses_all[,22],
payment_indicator10_output = responses_all[,11], payment_mean10_output = responses_all[,23],
payment_indicator11_output = responses_all[,12], payment_mean11_output = responses_all[,24])
#######################
### Hyperparameters ###
#######################
### Random seed for Keras
set.seed(100)
seed1 <- sample(1:1000000, 1)
### Starting values of the neural network
starting_values <- array(NA, dim=c(12,2))
for (i in 1:12){
starting_values[i,1] <- mean(data[data$AY+data$RepDel<=2006-i,8+i]>0)
starting_values[i,2] <- mean(log(data[data$AY+data$RepDel<=2006-i,8+i][data[data$AY+data$RepDel<=2006-i,8+i]>0]))
}
### Dropout rates
dropout_rates <- 1/c(2:11)
### Weights
network_weights <- array(NA,dim=c(12,2))
for (i in 1:12){
a <- as.numeric(data[data$AY+data$RepDel<=2006-i & data[,29+i]==1,8+i]>0)
b <- nrow(data)-length(a)
network_weights[i,1] <- -mean(c(a*log(mean(a))+(1-a)*log(1-mean(a)),rep(0,b)))
a <- log(data[data$AY+data$RepDel<=2006-i & data[,29+i]==1,8+i][data[data$AY+data$RepDel<=2006-i & data[,29+i]==1,8+i]>0])
b <- nrow(data)-length(a)
network_weights[i,2] <- mean(c((a-mean(a))^2,rep(0,b)))
}
network_weights <- 1/network_weights
### Numbers of neurons
neurons <- c(40,30,10)
### Epochs
epochs <- as.numeric(read.table(paste("./Results/NumbersOfEpochs/FirstTrainingStep/LoB",LoB,"/Number_of_Epochs_Embedding.txt", sep=""), header=TRUE, sep=";",row.names=1))
### Batchsize
batchsize <- 10000
###############################################
### Application of the neural network model ###
###############################################
k_clear_session()
model <- neural_network_train_embedding(seed1, neurons, dropout_rates, starting_values, network_weights)
fit = model %>% fit(x = features_all_input, y = responses_all_input, epochs = epochs, batch_size = batchsize, verbose = 0)
#########################
### Store the results ###
#########################
### Determine which of the model weights are embeddings
a <- get_weights(model)
embeddings <- c()
for (i in 1:length(a)){
if (nrow(a[[i]])>1 & is.element(nrow(a[[i]]),15:26)==FALSE & is.na(ncol(a[[i]]))==FALSE & ncol(a[[i]])==1){
embeddings <- c(embeddings,i)
}
}
write.table(embeddings, file=paste("./Results/Embeddings/LoB",LoB,"/Embedding_Weights_Indicator.txt", sep=""), sep=";", row.names=TRUE, col.names=NA)
### Store the embeddings
for (i in embeddings){
write.table(a[[i]], file=paste("./Results/Embeddings/LoB",LoB,"/Embedding_Weights_",i,".txt", sep=""), sep=";", row.names=TRUE, col.names=NA)
} I started to receive the error from the |
Can you please condense or isolate the issue more? Another take that gives a few more concrete recommendations on what an MRE is: |
@t-kalinowski Sure! Sorry for my misunderstanding, I'm new to the coding and machine learning. Here's a more condensed code, I only put the first line of code that seems to have the error Please import the dataset as well: data.txt library(keras)
library(plyr)
library(reticulate)
library(tensorflow)
neural_network_train_embedding <- function(seed1, neurons, dropout_rates, starting_values, network_weights){
### Seed
# use_session_with_seed(seed1)
set_random_seed(seed1)
### Dropout
dropout_1_1 <- layer_dropout(rate = dropout_rates[1])
### Inputs
dropout <- layer_input(shape = c(1), dtype = 'int32', name = 'dropout')
### Embeddings
dropout_embed <- dropout %>%
layer_embedding(input_dim = 1, output_dim = 1, trainable=FALSE, input_length = 1,
weights=list(matrix(c(1)))) %>%
layer_flatten
### Keras model
model <- keras_model(inputs = c(dropout))
model
}
#######################
### Hyperparameters ###
#######################
### Random seed for Keras
set.seed(100)
seed1 <- sample(1:1000000, 1)
### Starting values of the neural network
starting_values <- array(NA, dim=c(12,2))
for (i in 1:12){
starting_values[i,1] <- mean(data[data$AY+data$RepDel<=2006-i,8+i]>0)
starting_values[i,2] <- mean(log(data[data$AY+data$RepDel<=2006-i,8+i][data[data$AY+data$RepDel<=2006-i,8+i]>0]))
}
### Dropout rates
dropout_rates <- 1/c(2:11)
### Weights
network_weights <- array(NA,dim=c(12,2))
for (i in 1:12){
a <- as.numeric(data[data$AY+data$RepDel<=2006-i & data[,29+i]==1,8+i]>0)
b <- nrow(data)-length(a)
network_weights[i,1] <- -mean(c(a*log(mean(a))+(1-a)*log(1-mean(a)),rep(0,b)))
a <- log(data[data$AY+data$RepDel<=2006-i & data[,29+i]==1,8+i][data[data$AY+data$RepDel<=2006-i & data[,29+i]==1,8+i]>0])
b <- nrow(data)-length(a)
network_weights[i,2] <- mean(c((a-mean(a))^2,rep(0,b)))
}
network_weights <- 1/network_weights
### Numbers of neurons
neurons <- c(40,30,10)
### Epochs
epochs <- 30
### Batchsize
batchsize <- 10000
###############################################
### Application of the neural network model ###
###############################################
k_clear_session()
model <- neural_network_train_embedding(seed1, neurons, dropout_rates, starting_values, network_weights) And I received the error from here |
How did you read in 'data'? Would it be possible to dump it out using |
@t-kalinowski I use the data <- read.table("D:/data.txt", quote="\"", comment.char="")
View(data) Or using `dput()`:structure(list(ClNr = c(1L, 5L, 7L, 14L, 22L, 29L, 36L, 40L,
41L, 44L, 54L, 57L, 61L, 64L, 71L, 75L, 77L, 81L, 85L, 87L, 93L,
98L, 104L, 110L, 112L, 121L, 125L, 130L, 138L, 155L, 158L, 162L,
166L, 168L, 173L, 177L, 186L, 190L, 193L, 194L, 195L, 196L, 199L,
213L), LoB = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L
), cc = c(18L, 19L, 6L, 6L, 46L, 27L, 19L, 45L, 17L, 29L, 19L,
17L, 22L, 19L, 46L, 17L, 47L, 17L, 17L, 50L, 41L, 6L, 20L, 53L,
20L, 17L, 14L, 14L, 48L, 47L, 53L, 22L, 19L, 37L, 20L, 45L, 47L,
17L, 14L, 17L, 45L, 6L, 13L, 6L), AY = c(1994L, 1994L, 1994L,
1994L, 1994L, 1994L, 1994L, 1994L, 1994L, 1994L, 1994L, 1994L,
1994L, 1994L, 1994L, 1994L, 1994L, 1994L, 1994L, 1994L, 1994L,
1994L, 1994L, 1994L, 1994L, 1994L, 1994L, 1994L, 1994L, 1994L,
1994L, 1994L, 1994L, 1994L, 1994L, 1994L, 1994L, 1994L, 1994L,
1994L, 1994L, 1994L, 1994L, 1994L), AQ = c(3L, 1L, 3L, 1L, 3L,
1L, 1L, 1L, 3L, 3L, 3L, 4L, 1L, 3L, 4L, 2L, 1L, 1L, 3L, 4L, 4L,
3L, 4L, 1L, 4L, 3L, 3L, 1L, 1L, 4L, 4L, 2L, 1L, 4L, 1L, 3L, 2L,
1L, 2L, 4L, 2L, 2L, 3L, 1L), age = c(40L, 35L, 50L, 69L, 24L,
23L, 39L, 24L, 38L, 51L, 17L, 36L, 23L, 26L, 44L, 34L, 47L, 17L,
40L, 42L, 26L, 52L, 46L, 51L, 49L, 43L, 19L, 48L, 32L, 35L, 37L,
40L, 43L, 42L, 17L, 35L, 19L, 46L, 46L, 41L, 19L, 21L, 22L, 29L
), inj_part = c(52L, 61L, 53L, 23L, 35L, 60L, 36L, 15L, 41L,
53L, 70L, 36L, 53L, 12L, 53L, 35L, 53L, 55L, 54L, 36L, 12L, 36L,
41L, 42L, 37L, 34L, 12L, 12L, 11L, 36L, 50L, 53L, 55L, 35L, 51L,
64L, 34L, 50L, 36L, 53L, 12L, 36L, 71L, 36L), RepDel = c(0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
1L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L), Pay00 = c(1341L,
381L, 160L, 694L, 457L, 2005L, 554L, 400L, 279L, 731L, 215L,
515L, 255L, 82L, 0L, 574L, 1237L, 37L, 616L, 0L, 61L, 636L, 790L,
3370L, 460L, 361L, 153L, 88L, 85L, 0L, 61L, 429L, 24L, 313L,
172L, 868L, 8757L, 569L, 92L, 725L, 145L, 262L, 421L, 318L),
Pay01 = c(1028L, 0L, 0L, 0L, 0L, 959L, 0L, 0L, 0L, 0L, 0L,
344L, 0L, 0L, 577L, 0L, 0L, 0L, 0L, 146L, 0L, 0L, 913L, 0L,
0L, 0L, 0L, 0L, 0L, 145L, 0L, 0L, 0L, 0L, 0L, 0L, 6312L,
0L, 0L, 430L, 0L, 0L, 0L, 0L), Pay02 = c(548L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 563L, 0L,
0L, 0L, 0L, 0L, 426L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 5520L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), Pay03 = c(0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 3147L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), Pay04 = c(0L,
0L, 0L, 0L, 0L, 0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, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), Pay10 = c(0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), Pay11 = c(0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), RY = c(1994L,
1994L, 1994L, 1994L, 1994L, 1994L, 1994L, 1994L, 1994L, 1994L,
1994L, 1995L, 1994L, 1994L, 1994L, 1994L, 1994L, 1994L, 1994L,
1994L, 1994L, 1994L, 1994L, 1994L, 1995L, 1994L, 1994L, 1994L,
1994L, 1994L, 1994L, 1994L, 1994L, 1995L, 1994L, 1994L, 1994L,
1994L, 1994L, 1995L, 1994L, 1994L, 1994L, 1994L), RepDelnew = c(0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L), LoBx = c(0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), ccx = c(16L,
17L, 4L, 4L, 43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0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), PayInd11 = c(0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), LogPay00 = c(7.20117088328168,
5.9427993751267, 5.07517381523383, 6.5424719605068, 6.12468339089421,
7.60339933974067, 6.31716468674728, 5.99146454710798, 5.63121178182137,
6.59441345974978, 5.37063802812766, 6.24416690066374, 5.54126354515843,
4.40671924726425, 0, 6.35262939631957, 7.12044437239249,
3.61091791264422, 6.42324696353352, 0, 4.11087386417331,
6.45519856334012, 6.67203294546107, 8.12266802334641, 6.13122648948314,
5.88887795833288, 5.03043792139244, 4.47733681447821, 4.44265125649032,
0, 4.11087386417331, 6.06145691892802, 3.17805383034795,
5.74620319054015, 5.14749447681345, 6.76619171466035, 9.07760865952222,
6.34388043412633, 4.52178857704904, 6.58617165485467, 4.97673374242057,
5.5683445037611, 6.04263283368238, 5.76205138278018), LogPay01 = c(6.93537044601511,
0, 0, 0, 0, 6.86589107488344, 0, 0, 0, 0, 0, 5.8406416573734,
0, 0, 6.3578422665081, 0, 0, 0, 0, 4.98360662170834, 0, 0,
6.81673588059497, 0, 0, 0, 0, 0, 0, 4.97673374242057, 0,
0, 0, 0, 0, 0, 8.75020786252571, 0, 0, 6.06378520868761,
0, 0, 0, 0), LogPay02 = c(6.30627528694802, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6.33327962813969, 0, 0, 0,
0, 0, 6.05443934626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, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L)), class = "data.frame", row.names = c("1",
"3", "4", "6", "9", "11", "15", "17", "18", "20", "23", "26",
"29", "30", "32", "34", "36", "38", "39", "41", "43", "46", "51",
"54", "55", "58", "61", "63", "65", "70", "73", "76", "80", "81",
"83", "84", "88", "89", "91", "92", "93", "94", "97", "100")) |
The I recommend creating a project specific venv for this legacy project: virtualenv_create("./venv", version = ">=3.9,<=3.11", packages = c(
"tensorflow", "tf_keras" # legacy keras module
)) (Reticulate will automatically discover a "./venv" in the current working directory, see here for how reticulate selects a Python installation) Then, before initializing TensorFlow/Keras, make sure the env var is set Sys.setenv(TF_USE_LEGACY_KERAS=1)
library(tensorflow)
library(keras)
# use_virtualenv(<path/to/venv>) # if you don't use the default auto-discoverable "./venv" location
# <rest of code> |
Hi, thank you so much for helping me out. However, I tried to run the code and received this error: virtualenv_create("./venv", version = ">=3.9,<=3.11", packages = c("tensorflow", "tf_keras")) # legacy keras module
Error in stop_no_virtualenv_starter(version = version, python = python) :
Suitable Python installation for creating a venv not found.
Requested version constraint: >=3.9,<=3.11
Please install Python with one of following methods:
- https://www.python.org/downloads/
- reticulate::install_python(version = '<version>') Here's a full version of the code: library(reticulate)
virtualenv_create("./venv", version = ">=3.9,<=3.11", packages = c("tensorflow", "tf_keras")) # legacy keras module
Sys.setenv(TF_USE_LEGACY_KERAS=1)
library(tensorflow)
library(keras)
# use_virtualenv(<path/to/venv>) # if you don't use the default auto-discoverable "./venv" location
# <rest of code> I hope I got it right. And my current Python version is 3.11.9. |
Reticulate is not finding a Python that it can use to create the venv with. You can remedy by installing Python in one of the common locations by doing one of the options suggested in the error message (e.g., calling virtualenv_create("./venv", python = "/path/to/python.exe", packages = ...) |
I have tried > model <- neural_network_train_embedding(seed1, neurons, dropout_rates, starting_values, network_weights)
2024-04-08 13:12:28.097193: I tensorflow/core/platform/cpu_feature_guard.cc:210] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
Error in py_call_impl(callable, call_args$unnamed, call_args$named) :
ValueError: Unrecognized keyword arguments passed to Embedding: {'input_length': 1, 'weights': [array([[1.]])]}
Run `reticulate::py_last_error()` for details. |
MRE: library(keras)
layer_input(1, dtype = "int32") |>
layer_embedding(
input_dim = 1,
output_dim = 1,
input_length = 1,
weights = list(matrix(1))
)
#> Unrecognized keyword arguments passed to Embedding: {'input_length': 1,
#> 'weights': [array([[1.]])]} Created on 2024-04-08 with reprex v2.1.0 Fix: # reticulate::py_install("tf_keras")
Sys.setenv(TF_USE_LEGACY_KERAS=1)
library(keras)
layer_input(1, dtype = "int32") |>
layer_embedding(
input_dim = 1,
output_dim = 1,
input_length = 1,
weights = list(matrix(1))
) Created on 2024-04-08 with reprex v2.1.0 If you're having installation issues, can you please open a new issue with the information requested in https://github.com/rstudio/keras/blob/main/.github/ISSUE_TEMPLATE/installation-issue.md (i.e., the exact commands you are running, and the output from |
This comment was marked as duplicate.
This comment was marked as duplicate.
Hi, thanks for your help. The problem with the library(keras)
library(plyr)
library(reticulate)
library(tensorflow)
neural_network_train_embedding <- function(seed1, neurons, dropout_rates, starting_values, network_weights){
### Seed
# use_session_with_seed(seed1)
set_random_seed(seed1)
hidden_0_pre <- features_input %>%
layer_dense(units=neurons[1], activation='linear')
hidden_0 <- list(hidden_0_pre, AY_embed_input_NN) %>%
layer_add %>%
layer_dense(units=neurons[1], activation='tanh', trainable = FALSE,
weights = list(diag(1,neurons[1]),array(0,dim=c(neurons[1])))) %>%
layer_dense(units=neurons[2], activation='tanh')
payment_indicator00_pre <- hidden_0 %>%
layer_dense(units=neurons[3], activation='tanh')
payment_indicator00_pre2 <- list(payment_indicator00_pre, features_output) %>%
layer_concatenate(name = "pay_ind00") %>%
layer_dense(units = 1, activation='linear',
weights = list(array(rep(0,neurons[3]+5),dim=c(neurons[3]+5,1)),array(log(starting_values[1,1]/(1-starting_values[1,1])),dim=c(1))))
payment_indicator00 <- list(payment_indicator00_pre2, AY_output_indicator) %>%
layer_add %>%
layer_dense(units = 1, activation = 'sigmoid', trainable = FALSE,
weights = list(array(1,dim=c(1,1)),array(0,dim=c(1))))
Time_Predict_Indicator00 <- layer_input(shape = c(1), dtype = 'float32', name = 'Time_Predict_Indicator00')
payment_indicator00_output <- list(payment_indicator00, Time_Predict_Indicator00) %>%
layer_multiply(name = 'payment_indicator00_output')
### Keras model
model <- keras_model(inputs = c(dropout))
model
}
#######################
### Hyperparameters ###
#######################
### Random seed for Keras
set.seed(100)
seed1 <- sample(1:1000000, 1)
### Starting values of the neural network
starting_values <- array(NA, dim=c(12,2))
for (i in 1:12){
starting_values[i,1] <- mean(data[data$AY+data$RepDel<=2006-i,8+i]>0)
starting_values[i,2] <- mean(log(data[data$AY+data$RepDel<=2006-i,8+i][data[data$AY+data$RepDel<=2006-i,8+i]>0]))
}
### Dropout rates
dropout_rates <- 1/c(2:11)
### Weights
network_weights <- array(NA,dim=c(12,2))
for (i in 1:12){
a <- as.numeric(data[data$AY+data$RepDel<=2006-i & data[,29+i]==1,8+i]>0)
b <- nrow(data)-length(a)
network_weights[i,1] <- -mean(c(a*log(mean(a))+(1-a)*log(1-mean(a)),rep(0,b)))
a <- log(data[data$AY+data$RepDel<=2006-i & data[,29+i]==1,8+i][data[data$AY+data$RepDel<=2006-i & data[,29+i]==1,8+i]>0])
b <- nrow(data)-length(a)
network_weights[i,2] <- mean(c((a-mean(a))^2,rep(0,b)))
}
network_weights <- 1/network_weights
### Numbers of neurons
neurons <- c(40,30,10)
### Epochs
epochs <- 30
### Batchsize
batchsize <- 10000
###############################################
### Application of the neural network model ###
###############################################
k_clear_session()
model <- neural_network_train_embedding(seed1, neurons, dropout_rates, starting_values, network_weights) I received this error: > model <- neural_network_train_embedding(seed1, neurons, dropout_rates, starting_values, network_weights)
Error in py_call_impl(callable, call_args$unnamed, call_args$named) :
KeyError: 0
Run `reticulate::py_last_error()` for details.
6. stop(<environment>)
5. (structure(function (inputs, ...)
{
cl <- sys.call()
cl[[1L]] <- list2 ...
4. do.call(keras$layers$multiply, c(list(inputs), dots$named))
3. layer_multiply(., name = "payment_indicator00_output")
2. list(payment_indicator00, Time_Predict_Indicator00) %>% layer_multiply(name = "payment_indicator00_output")
1. neural_network_train_embedding(seed1, neurons, dropout_rates,
starting_values, network_weights) From what I know, The Thanks again for your support! |
This comment was marked as duplicate.
This comment was marked as duplicate.
Can you please post an MRE (the above is not minimal enough). You can call |
Hi, sorry for the late response. That is the shortest MRE I could provide. I received error for the following line of code: I also tried But I still received the error like I posted in the previous post. |
Can you please make your MRE self contained? Please use the reprex package: https://reprex.tidyverse.org |
Hi, here's the MRE. Thanks again for your help! library(keras)
library(plyr)
hidden_0_pre <- features_input %>%
layer_dense(units=neurons[1], activation='linear')
hidden_0 <- list(hidden_0_pre, AY_embed_input_NN) %>%
layer_add %>%
layer_dense(units=neurons[1], activation='tanh', trainable = FALSE,
weights = list(diag(1,neurons[1]),array(0,dim=c(neurons[1])))) %>%
layer_dense(units=neurons[2], activation='tanh')
payment_indicator00_pre <- hidden_0 %>%
layer_dense(units=neurons[3], activation='tanh')
payment_indicator00_pre2 <- list(payment_indicator00_pre, features_output) %>%
layer_concatenate(name = "pay_ind00") %>%
layer_dense(units = 1, activation='linear',
weights = list(array(rep(0,neurons[3]+5),dim=c(neurons[3]+5,1)),array(log(starting_values[1,1]/(1-starting_values[1,1])),dim=c(1))))
payment_indicator00 <- list(payment_indicator00_pre2, AY_output_indicator) %>%
layer_add %>%
layer_dense(units = 1, activation = 'sigmoid', trainable = FALSE,
weights = list(array(1,dim=c(1,1)),array(0,dim=c(1))))
Time_Predict_Indicator00 <- layer_input(shape = c(1), dtype = 'float32', name = 'Time_Predict_Indicator00')
payment_indicator00_output <- list(payment_indicator00, Time_Predict_Indicator00) %>%
layer_multiply(name = 'payment_indicator00_output') |
When I try to run the reprex, I see: Error:
! object 'neurons' not found
Run `rlang::last_trace()` to see where the error occurred.
> rlang::last_trace()
<error/rlang_error>
Error:
! object 'neurons' not found
---
Backtrace:
▆
1. ├─base::source("~/.active-rstudio-document")
2. │ ├─base::withVisible(eval(ei, envir))
3. │ └─base::eval(ei, envir)
4. │ └─base::eval(ei, envir)
5. ├─features_input %>% ... at ~/.active-rstudio-document:4:1
6. └─keras::layer_dense(., units = neurons[1], activation = "linear")
7. └─keras::create_layer(...) Please use |
Automatically closed because there has not been a response for 30 days. When you're ready to work on this further, please comment here and the issue will automatically reopen. |
Hi all,
I am trying to run a code published by: Gabriella Andrea. I use the provided dataset that comes along with the code. I start with the NeuralNetworkModels file, works just fine. Then I continue with the EmbeddingWeights file, and the problem begins here.
Details about the error will be shown below. I did try to reinstall R and Python, and updated all relevant packages. From what I understand about the error, there might seems to be a conflict between the R code for the layer_embedding command, and the embedding command from Python. I didn't change any of the original code, and from what I know, the command follows the correct arguments and usage as described here.
Please help, I have been stuck on this error for almost a week now.
Starting from the "Application of Neural Network Model" part (line 177) of the EmbeddingWeights file, I received the following error:
I followed the instruction and tried the reticulate::py_last_error() code:
Here's a more detailed explanation I receive from the error:
The text was updated successfully, but these errors were encountered: