0

I am writing a program to train a convnet to colorize grey scale image to CIELab image. Following is how my code goes:

with open('mypicklegrey.pickle','rb') as fgrey:
   X_train = pickle.load(fgrey)
   print ('data_grey')



with open('mypicklelab.pickle','rb') as flab:
   Y_train = pickle.load(flab)
   print ('data_lab')

net1 = NeuralNet(
layers=[('input', layers.InputLayer),
        ('conv2d1', layers.Conv2DLayer),
        ('maxpool1', layers.MaxPool2DLayer),
        ('conv2d2', layers.Conv2DLayer),
        ('maxpool2', layers.MaxPool2DLayer),
        ('dropout1', layers.DropoutLayer),
        ('dense', layers.DenseLayer),
        ('dropout2', layers.DropoutLayer),
        ('output', layers.DenseLayer),

        ],
# input layer
input_shape=(None, 1, 224,224),
# layer conv2d1
conv2d1_num_filters=32,
conv2d1_filter_size=(3, 3),
conv2d1_nonlinearity=lasagne.nonlinearities.rectify,
conv2d1_W=lasagne.init.GlorotUniform(),  
# layer maxpool1
maxpool1_pool_size=(2, 2),    
# layer conv2d2
conv2d2_num_filters=32,
conv2d2_filter_size=(3, 3),
conv2d2_nonlinearity=lasagne.nonlinearities.rectify,
# layer maxpool2
maxpool2_pool_size=(2, 2),
# dropout1
dropout1_p=0.5,  

# dense
dense_num_units=256,
dense_nonlinearity=lasagne.nonlinearities.rectify,    
# dropout2
dropout2_p=0.5,

# output
output_nonlinearity=lasagne.nonlinearities.softmax,
output_num_units=10,
# optimization method params
update=nesterov_momentum,
update_learning_rate=0.01,
update_momentum=0.9,
max_epochs=10,

verbose=1,
)

Above code is running perfectly, but I'm getting the error while training net.

nn = net1.fit(X_train, Y_train)

ERROR------------line 350, in _check_good_input->x_len = len(X) TypeError: object of type 'Image' has no len()

I'm new in programming neural nets and didn't really get what exactly is the cause of this error, kind of stuck at this point. Any help is much appreciated. Thanks in advance!

  • 1
    What are the types of X_train and Y_train? Typically it is expected them to be numpy arrays, which doesn't seem to be the case. – Dr. Snoopy Mar 20 '17 at 14:04
  • @MatiasValdenegro They are 'Image' instances. Yes, they aren't numpy arrays. Thanks! I'll change that part. – Kshitija Hande Mar 20 '17 at 17:00

0 Answers0