1

i'm trying to learn about convolution neural network using tensorflow , i'm using the code bellow to create my network .

    # network weights
    W_conv1 = weight_variable([8, 8, 4, 32])
    b_conv1 = bias_variable([32])

    W_conv2 = weight_variable([4, 4, 32, 64])
    b_conv2 = bias_variable([64])

    W_conv3 = weight_variable([3, 3, 64, 64])
    b_conv3 = bias_variable([64])

    W_fc1 = weight_variable([1600, 512])
    b_fc1 = bias_variable([512])

    W_fc2 = weight_variable([512, ACTIONS])
    b_fc2 = bias_variable([ACTIONS])

    # input layer
    s = tf.placeholder("float", [None, 80, 80, 4])

    # hidden layers
    h_conv1 = tf.nn.relu(conv2d(s, W_conv1, 4) + b_conv1)
    h_pool1 = max_pool_2x2(h_conv1)

    h_conv2 = tf.nn.relu(conv2d(h_pool1, W_conv2, 2) + b_conv2)
    #h_pool2 = max_pool_2x2(h_conv2)

    h_conv3 = tf.nn.relu(conv2d(h_conv2, W_conv3, 1) + b_conv3)
    #h_pool3 = max_pool_2x2(h_conv3)

    #h_pool3_flat = tf.reshape(h_pool3, [-1, 256])
    h_conv3_flat = tf.reshape(h_conv3, [-1, 1600])

    h_fc1 = tf.nn.relu(tf.matmul(h_conv3_flat, W_fc1) + b_fc1)

    # readout layer
    readout = tf.matmul(h_fc1, W_fc2) + b_fc2

this network take a [80,80,4] object an output a ACTIONS prediction ;(ACTIONS number of classes)

My question is how to create a network that output a value between [a,b]

un famous
  • 35
  • 1
  • 11

1 Answers1

0

if [a,b] is categorical, i.e. you have discrete classes (say n in total), you need to have n neurons as in readout layer, each corresponding to a given class representing its probability. Standard way to do it is using sigmoid cross entropy on logits (using tf.nn.sigmoid_cross_entropy_with_logits in case of tensorflow).

In case [a,b] is continuous (which I believe is probably not what you are looking to do) than it becomes a regression problem. So, given sufficient data and an appropriate loss function (squared errors) along with some regularization should ensure your output lies in acceptable range or you can always map one numeric range to another.

If none of this makes sense, you need to study some basic machine learning before you dive into neural nets.

rajat
  • 864
  • 1
  • 9
  • 23