cloudml icon indicating copy to clipboard operation
cloudml copied to clipboard

export_savedmodel

Open philipus opened this issue 5 years ago • 1 comments

export_savedmodel using cloudml did not work properly (see below) on google AI Platform.

How do you save and download the model for further steps (applying model on new data) on local computer?!

Error: ValueError: Attempted to save a function __inference_lstm_layer_call_fn_8346 which references a symbolic Tensor Tensor("dropout/mul_1:0", shape=(?, 1), dtype=float32) that is not a simple constant. This is not supported. Detailed traceback: File "//usr/local/lib/python2.7/dist-packages/tensorflow_core/python/saved_model/save.py", line 860, in save meta_graph_def, saveable_view, signatures) File "//usr/local/lib/python2.7/dist-packages/tensorflow_core/python/saved_model/save.py", line 556, in _fill_meta_graph_def object_map, resource_map, asset_info = saveable_view.map_resources() File "//usr/local/lib/python2.7/dist-packages/tensorflow_core/python/saved_model/save.py", line 291, in map_resources "supported.").format(concrete_function.name, capture)) py_call_impl(callable, dots$args, dots$keywords) tensorflow::tf$saved_model$save(obj = object, export_dir = export_dir_base, ...) export_savedmodel.keras.engine.training.Model(model, "savedmodel") export_savedmodel(model, "savedmodel") eval(ei, envir) eval(ei, envir) withVisible(eval(ei, envir)) source(file = file, local = envir, echo = echo, encoding = encoding) withCallingHandlers({ source(file = file, local = envir, echo = echo, encoding = encoding) write_run_property("completed", TRUE) }, error = function(e) { write_run_metadata("error", list(message = e$message, traceback = capture_stacktrace(sys.calls()))) stop(e) }) force(expr) tryCatch({ tfruns::training_run(file = deploy$entrypoint, context = deploy$context, config = "cloudml", flags = deploy$overlay, encoding = "UTF-8", echo = TRUE, view = FALSE, run_dir = run_dir) }, error = function(e) { training_error <<- e })

philipus avatar May 16 '20 19:05 philipus

very strange habit... with train.R form https://cran.r-project.org/web/packages/cloudml/vignettes/deployment.html

export_savedmodel works but with my code (the part below) not. Any Idea what the problem is?!


model <- keras_model( inputs = list(encoder_inputs, decoder_inputs), outputs = decoder_outputs )

Compile model

model %>% compile(optimizer='adam', loss='mean_absolute_error')

model %>% fit( list(encoder_input_data, decoder_input_data), decoder_target_data, batch_size=batch_size, epochs=epochs, validation_split=0.2)

export_savedmodel(model, "savedmodel")

philipus avatar May 17 '20 18:05 philipus