0

I am using keras in R for a classification problem.

I used model <- keras_model_sequential() with 3 layers

parallel.model <- multi_gpu_model(model, gpus=2)

parallel.model %>% compile(
  loss = loss_binary_crossentropy,
  optimizer = optimizer_adam(lr = 0.001, epsilon = 1e-08),
  metrics = c("accuracy"))

parallel.model %>% fit(
  train.x,
  y.train,
  epochs = 50,
  batch_size = 256,
  validation_split = 0.2)

When I used

 y.test.hat <- parallel.model %>% predict_classes(test.y)

I got this error:

Error in py_get_attr_impl(x, name, silent) : 
  AttributeError: 'Model' object has no attribute 'predict_classes'
Calls: %>% ... py_get_attr_or_item -> py_get_attr -> py_get_attr_impl

Is it because parallel.model is not sequential? Because I got the same error when I used:

 parallel.model %>% pop_layer()
desertnaut
  • 57,590
  • 26
  • 140
  • 166
Noura
  • 474
  • 2
  • 11
  • Leave the pipe operator aside and try `y.test.hat <- predict_classes(parallel.model, test.x)` (I suppose `test.y` you have in your code is a typo); does it work? – desertnaut Feb 16 '19 at 09:29
  • No, it didn't work. I got this error: AttributeError: 'Model' object has no attribute 'predict_classes' – Noura Feb 21 '19 at 17:01
  • 1
    Possible duplicate of [AttributeError: 'Model' object has no attribute 'predict\_classes'](https://stackoverflow.com/questions/44806125/attributeerror-model-object-has-no-attribute-predict-classes) – divibisan Mar 22 '19 at 16:06

0 Answers0