I have a python script that makes a keras model using plaidml backend
the relevant parts of the script are
from __future__ import print_function
import plaidml.keras
plaidml.keras.install_backend()
import os
os.environ["KERAS_BACKEND"] = "plaidml.keras.backend"
os.environ['KMP_DUPLICATE_LIB_OK']='True'
import numpy as np
from keras.preprocessing.image import img_to_array
from keras.models import Sequential, Model
from keras.layers import Dense, Dropout, Flatten, Activation, Input
from keras.layers import Conv2D, MaxPooling2D
from keras import backend as K
from keras.preprocessing.image import ImageDataGenerator
from sklearn.model_selection import train_test_split
import pandas as pd
import time
import glob
import cv2
import keras
from keras_tqdm import TQDMNotebookCallback
and
model = Sequential()
model.add(Conv2D(32,kernel_size=3,input_shape=(3,1920,1080),strides=1,padding='same'))
model.add(Activation('relu'))
model.add(Conv2D(32,kernel_size=3,strides=1,padding='same'))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Dropout(0.25))
model.add(Conv2D(64,kernel_size=3,strides=1,padding='same'))
model.add(Activation('relu'))
model.add(Conv2D(64,kernel_size=2,strides=1, padding='same'))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Dropout(0.25))
model.add(Flatten())
model.add(Dense(512))
model.add(Activation('relu'))
model.add(Dropout(0.5))
model.add(Dense(num_classes))
model.add(Activation('softmax'))
Whenever I run this I get this output.
Found 30 images belonging to 2 classes.
Found 30 images belonging to 1 classes. INFO:plaidml:Opening device "opencl_amd_gfx1030.0" Traceback (most recent call last): File "C:\Users\p\Documents\model_train.py", line 78, in model.add(Flatten()) File "C:\Users\p\python\lib\site-packages\keras\engine\sequential.py", line 181, in add output_tensor = layer(self.outputs[0]) File "C:\Users\p\python\lib\site-packages\keras\engine\base_layer.py", line 474, in call output_shape = self.compute_output_shape(input_shape) File "C:\Users\p\python\lib\site-packages\keras\layers\core.py", line 500, in compute_output_shape '(got ' + str(input_shape[1:]) + '. ' ValueError: The shape of the input to "Flatten" is not fully defined (got (0, 480, 64). Make sure to pass a complete "input_shape" or "batch_input_shape" argument to the first layer in your model.
I also used to get an invalid computed convolution out size error but I fixed that by setting padding to same and stride to 1
I tried to use a python script to create a keas h5 model.I was expecting the script to create a model instead I got an error saying the input shape is not complete even though based on what I read in the docs it is