0
votes

I built my image classification DNN model in python3 code locally and I am trying to send my model to Watson for training. I created 2 buckets in Watson Studio for 1) training- to store train dataset, which consists of images - and 2) storing the results. I have saved data opening and preprocessing, and my network architecture and training code in as "GTS_Model.zip" to send to Watson for training. My train set as pickle file (.p), and in my model code I open the file and start working with it then train on it. however I am receiving this error message when I start the training and I can't seem to find what the issue is. The code below is the part in my GTS_Model.zip code where I open the data file from the training bucket. 4th line is throwing the following error:

Traceback (most recent call last):
 File "GTS_Model.py", line 47, in <module>
   with open(training_file, mode='rb') as f:
TypeError: invalid file: <_io.TextIOWrapper name='/mnt/data/training-data-ff865095-a50d-4ac1-b037-c22ae7cf958f/train.p' mode='r' encoding='ANSI_X3.4-1968'>
Training exited with error code 1
Failed: learner_exit_code: 1

I initially suspected that the datafile type is unsupported but by looking into supported data file types for Watson found that pickle files are accepted. So not sure why the file won't open.

input_data_folder = os.environ["DATA_DIR"]

training_file = open(os.path.join(input_data_folder,"train.p"))
testing_file = open(os.path.join(input_data_folder,"test.p"))

with open(training_file, mode='rb') as f:
   train = pickle.load(f)
with open(testing_file, mode='rb') as f:
   test = pickle.load(f)

X_train, y_train = train['features'], train['labels']
X_test, y_test = test['features'], test['labels']
1

1 Answers

0
votes

It looks like the issue is in the mode='r' and encoding since this is almost certainly not 'ANSI_X3.4-1968' I think

Here is a blog post that shows to use the deep learning services with python pickle objects https://medium.com/ibm-watson/exploring-deep-learning-and-neural-network-modeler-with-watson-studio-ead35d21a438