Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (19.9k points)

I am running a TensorFlow job on google ai-platform. After the model is trained I want to save model.history to file. Since I need to write to a cloud storage bucket I use tf.io.write_file. I have tried the following:

hist=mymodel.fit(training_dataset_input,epochs=num_epochs,steps_per_epoch=int(training_samples/batch_size),validation_data=validation_dataset_input,validation_steps=1,verbose=1,callbacks[mycallbacks,tensorboard_cb,csv_logger])

tf.io.write_file(gs://<nameofbucket>/<nameoffile>,hist.history)

I get the following error message:

ValueError: Attempt to convert a value ({'loss': [355.3313500958558, 313.9355358472616], 'mean_squared_error': [355.3312, 313.93536], 'find_rms': [14.733875, 13.815437], 'val_loss': [292.5752868652344, 270.8216857910156], 'val_mean_squared_error': [292.5753, 270.8217], 'val_find_rms': [13.506351, 12.935535]}) with an unsupported type (<class 'dict'>) to a Tensor.

It looks like hist.history is a dictionary with strings as keys and lists as values. How can I get hist.history in the right format so that it can be written to file using tf.io.write_file?

1 Answer

0 votes
by (25.1k points)

Convert the dictionary into a list and then save it. If you want to visualize the saved data easily, you can maybe save it as C.S.V.

Browse Categories

...