我正在Rstudio中使用Keras进行深度学习。我在模型的开头有一些嵌入层。我检查了连续变量,没有缺失值,并且响应变量y为float。
df_cl_dl = df_cl %>% filter(agency == "FHA") %>%
select(lender, channel, fthb, region, credit_score, credit_score_null, source, ltv_uw, seasonality,
current_ltv, loan_age, cash_incentive_a, hpas, loan_size, ur, risk,
vsmm) %>%
sample_n(100000)
inp_lender = layer_input(shape = c(1), name = "inp_lender")
inp_channel = layer_input(shape = c(1), name = "inp_channel")
inp_fthb = layer_input(shape = c(1), name = "inp_fthb")
inp_region = layer_input(shape = c(1), name = "inp_region")
inp_cs_null = layer_input(shape = c(1), name = "inp_cs_null")
inp_source = layer_input(shape = c(1), name = "inp_source")
inp_season = layer_input(shape = c(1), name = "inp_season")
inp_ltv_uw = layer_input(shape = c(1), name = "inp_ltv_uw")
inp_continuous = layer_input(shape = c(8), name = "inp_continuous")
embedding_out1 = inp_lender %>% layer_embedding(input_dim = 3+1, output_dim = 2, input_length = 1, name = "embedding_lender") %>% layer_flatten()
embedding_out2 = inp_channel %>% layer_embedding(input_dim = 3+1, output_dim = 2, input_length = 1, name = "embedding_channel") %>% layer_flatten()
embedding_out3 = inp_fthb %>% layer_embedding(input_dim = 3+1, output_dim = 2, input_length = 1, name = "embedding_fthb") %>% layer_flatten()
embedding_out4 = inp_region %>% layer_embedding(input_dim = 4+1, output_dim = 2, input_length = 1, name = "embedding_region") %>% layer_flatten()
embedding_out5 = inp_cs_null %>% layer_embedding(input_dim = 2+1, output_dim = 2, input_length = 1, name = "embedding_cs_null") %>% layer_flatten()
embedding_out6 = inp_source %>% layer_embedding(input_dim = 2+1, output_dim = 2, input_length = 1, name = "embedding_source") %>% layer_flatten()
embedding_out7 = inp_season %>% layer_embedding(input_dim = 12+1, output_dim = 3, input_length = 1, name = "embedding_season") %>% layer_flatten()
embedding_out8 = inp_ltv_uw %>% layer_embedding(input_dim = 2+1, output_dim = 2, input_length = 1, name = "embedding_ltv_uw") %>% layer_flatten()
combined_model = layer_concatenate(c(embedding_out1, embedding_out2, embedding_out3, embedding_out4,
embedding_out5, embedding_out6, embedding_out7, embedding_out8, inp_continuous)) %>%
layer_dense(units=32, activation = "relu") %>%
layer_dropout(0.3) %>%
layer_dense(units=10, activation = "relu") %>%
layer_dropout(0.15) %>%
layer_dense(units=1)
model = keras::keras_model(inputs = c(inp_lender, inp_channel, inp_fthb, inp_region, inp_cs_null,
inp_source, inp_season, inp_ltv_uw, inp_continuous),
outputs = combined_model)
model %>% compile(loss = "mean_squared_error", optimizer = "sgd", metric = "accuracy")
inputVariables = list(as.matrix(df_cl_dl$lender),
as.matrix(df_cl_dl$channel),
as.matrix(df_cl_dl$fthb),
as.matrix(df_cl_dl$region),
as.matrix(df_cl_dl$credit_score_null),
as.matrix(df_cl_dl$source),
as.matrix(df_cl_dl$seasonality),
as.matrix(df_cl_dl$ltv_uw),
as.matrix(df_cl_dl[,c("credit_score", "current_ltv", "loan_age", "cash_incentive_a", "hpas", "loan_size", "ur", "risk")]))
model %>% fit(x = inputVariables, y = as.matrix(df_cl_dl$vsmm), epochs = 10, batch_size = 2)
错误消息:
py_call_impl(可调用,dots $ args,dots $ keywords)中的错误:ValueError:无法将字符串转换为浮点型:空