# How to create a dummy model in Tensorflow

I am a newbie in Machine learning.

I found this example using tflearn somewhere. It is the part of the program where we initialize a dummy model before training it. In the example, there were 4 input layers and 2 output layers. I didn't understand any terms but I ran that program and it worked.

def neural_network_model(input_size):
network = input_data(shape=[None, input_size, 1], name='input')

network = fully_connected(network, 128, activation='relu')
network = dropout(network, 0.8)

network = fully_connected(network, 256, activation='relu')
network = dropout(network, 0.8)

network = fully_connected(network, 512, activation='relu')
network = dropout(network, 0.8)

network = fully_connected(network, 256, activation='relu')
network = dropout(network, 0.8)

network = fully_connected(network, 128, activation='relu')
network = dropout(network, 0.8)

network = fully_connected(network, 2, activation='softmax')
network = regression(network, optimizer='adam', learning_rate=LR, loss='categorical_crossentropy', name='targets')
model = tflearn.DNN(network, tensorboard_dir='log')

return model


I wanted to reuse this function to create a model that I will train with a data having 24 input layers and 4 output layers but it gave me the following error:

Cannot feed value of shape (64, 4) for Tensor 'targets/Y:0', which has shape '(?, 2)'

Can someone explain me what does all of the term above mean ? And what should I change to adapt with my 24 by 4 layer?

The reason is that in your model, you have specified the input size to vary, as the parameter of your function specifies. You have to change your code as follows:

def neural_network_model(input_size, output_size):
network = input_data(shape=[None, input_size, 1], name='input')

network = fully_connected(network, 128, activation='relu')
network = dropout(network, 0.8)

network = fully_connected(network, 256, activation='relu')
network = dropout(network, 0.8)

network = fully_connected(network, 512, activation='relu')
network = dropout(network, 0.8)

network = fully_connected(network, 256, activation='relu')
network = dropout(network, 0.8)

network = fully_connected(network, 128, activation='relu')
network = dropout(network, 0.8)

network = fully_connected(network, output_size, activation='softmax')
network = regression(network, optimizer='adam', learning_rate=LR, loss='categorical_crossentropy', name='targets')
model = tflearn.DNN(network, tensorboard_dir='log')

return model


You have hard coded the output size, which is two, you have to change it to be a variable and during calling, you have to specify the size of your new output, which is four.