Q1. How to initialize variables? Is the code correct?
Use tf.get_variable or switch to slim (it will automatically initialize you). example
Q2: Is it possible to set the learning speed in the log scale?
You can, but do you need it? This is not the first thing you need to decide on this network. Please check # 3
However, for reference only, use the following notation.
learning_rate_node = tf.train.exponential_decay (learning_rate = 0.001, decay_steps = 10000, decay_rate = 0.98, ladder = True)
optimizer = tf.train.AdamOptimizer (learning_rate = learning_rate_node) .minimize (loss)
Q3: How to create the loss function described above?
At first you did not write βpredβ for the βimageβ of conversion to this message (on the basis of paper you need to apply subtraction and IDWT to get the final image).
There is one problem here: logits should be calculated based on the data of your labels. those. if you will use marked data as "Y: Label", you need to write
pred = model ()
pred = tf.matmul (pred, weight) + offsets
logits = tf.nn.softmax (pred)
loss = tf.reduce_mean (tf.abs (logits - labels))
This will give you the output Y: the shortcut to be used
If your dataset, labeled as an image, is labeled, then you need to follow this:
pred = model ()
pred = tf.matmul (image, weight) + offsets
logits = tf.nn.softmax (pred)
image = apply_IDWT ("X: input", logs) # this will apply IDWT (x_label - y_label)
loss = tf.reduce_mean (tf.abs (image labels))
Logs are the output of your network. You will use this as a result to calculate the rest. Instead of matmul, you can add a conv2d layer here without normalizing the batch and activation function and set the number of output functions to 4. Example:
pred = model ()
pred = slim.conv2d (pred, 4, [3, 3], activation_fn = None, padding = 'SAME', scope = 'output')
logits = tf.nn.softmax (pred)
image = apply_IDWT ("X: input", logs) # this will apply IDWT (x_label - y_label)
loss = tf.reduce_mean (tf.abs (logits - labels))
This loss function will give you basic training opportunities. However, this distance is L1, and a number of problems ( check ) may occur. Think about the following situation
Say you have the following array as an output [10, 10, 10, 0, 0], and you are trying to reach [10, 10, 10, 10, 10]. In this case, your loss is 20 (10 + 10). However, you have 3/5 success. In addition, this may indicate some outfit.
In this case, we consider the following result [6, 6, 6, 6, 6]. He still has a loss of 20 (4 + 4 + 4 + 4 + 4). However, when you apply threshold 5, you can succeed 5/5. Therefore, this is the case that we want.
If you use L2 loss, for the first case you will have 10 ^ 2 + 10 ^ 2 = 200 as the loss output. In the second case, you get 4 ^ 2 * 5 = 80. Therefore, the optimizer will try to run away from # 1 as quickly as possible in order to achieve global success, and not the complete success of some results and the complete failure of others. You can use the loss function for this.
tf.reduce_mean (tf.nn.l2_loss (logits - image))
Alternatively, you can check the cross-entropy loss function. (he applies softmax internally, do not use softmax twice)
tf.reduce_mean (tf.nn.softmax_cross_entropy_with_logits (pred, image))