Issue with Deep Learning - TechRepublic
Question
March 28, 2023 at 10:12 AM
RoxenJ

Issue with Deep Learning

by RoxenJ . Updated 3 years, 2 months ago

I’m having a problem with a deep-learning project I’m working on. I’m trying to implement a convolutional neural network but I’m running into an issue with the code.

I’m getting an error saying “TypeError: unsupported operand type(s) for +: ‘NoneType’ and ‘int'”. Below is the code I’m having trouble with:
def convolutional_neural_network(x):
weights = {‘w_conv1’:tf.Variable(tf.random_normal([5,5,1,32])),
‘w_conv2’:tf.Variable(tf.random_normal([5,5,32,64])),
‘w_fc’:tf.Variable(tf.random_normal([7*7*64,1024])),
‘out’:tf.Variable(tf.random_normal([1024, n_classes]))}

biases = {‘b_conv1’:tf.Variable(tf.random_normal([32])),
‘b_conv2’:tf.Variable(tf.random_normal([64])),
‘b_fc’:tf.Variable(tf.random_normal([1024])),
‘out’:tf.Variable(tf.random_normal([n_classes]))}

x = tf.reshape(x, shape=[-1, 28, 28, 1])

conv1 = tf.nn.relu(conv2d(x, weights[‘w_conv1’]) + biases[‘b_conv1’])
conv1 = maxpool2d(conv1)

conv2 = tf.nn.relu(conv2d(conv1, weights[‘w_conv2’]) + biases[‘b_conv2’])
conv2 = maxpool2d(conv2)

fc = tf.reshape(conv2,[-1, 7*7*64])
fc = tf.nn.relu(tf.matmul(fc, weights[‘w_fc’])+biases[‘b_fc’])

output = tf.matmul(fc, weights[‘out’])+biases[‘out’]

return output

I’m not sure what is causing the issue, any help would be greatly appreciated

Note: off-topic link removed by moderator.

This discussion is locked

All Comments