TensorflowでYOLOv3を写経した話

F0e950c6bf20815f3d169f063d3c5d4f?s=47 Aipa
January 12, 2019

 TensorflowでYOLOv3を写経した話

F0e950c6bf20815f3d169f063d3c5d4f?s=128

Aipa

January 12, 2019
Tweet

Transcript

  1. 12.
  2. 16.
  3. 20.
  4. 25.
  5. 27.
  6. 29.

    Tensorflow Πϯετʔϧ $ pip3 install --upgrade tensorflow Collecting tensorflow Could

    not find a version that satisfies the requirement tensorflow (from versions: ) No matching distribution found for tensorflow ݟ͔ͭΒͳ͍ͱ͸ɾɾɾɾʁ
  7. 31.

    ʗ(^o^)ʘ Traceback (most recent call last): File "YOLO_small_tf.py", line 3,

    in <module> import tensorflow as tf File "/opt/conda/lib/python3.7/site-packages/tensorflow/__init__.py", line 22, in <module> from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import File "/opt/conda/lib/python3.7/site-packages/tensorflow/python/ __init__.py", line 49, in <module> from tensorflow.python import pywrap_tensorflow File "/opt/conda/lib/python3.7/site-packages/tensorflow/python/ pywrap_tensorflow.py", line 58, in <module> from tensorflow.python.pywrap_tensorflow_internal import * File "/opt/conda/lib/python3.7/site-packages/tensorflow/python/ pywrap_tensorflow_internal.py", line 114 def TFE_ContextOptionsSetAsync(arg1, async): ^ SyntaxError: invalid syntax
  8. 43.

    ࣮૷ͷ࿩ tf.contrib.slim with slim.arg_scope([slim.max_pool2d], padding=‘SAME’): # Layer01 h_conv1 = slim.conv2d(x_image,

    32, [5, 5]) h_pool1 = slim.max_pool2d(h_conv1, [2, 2]) # Layer02 h_conv2 = slim.conv2d(h_pool1, 64, [5, 5]) h_pool2 = slim.max_pool2d(h_conv2, [2, 2]) # Layer03 h_pool2_flat = slim.flatten(h_pool2) h_fc1 = slim.fully_connected(h_pool2_flat, 1024)
  9. 45.

    ࣮૷ͷ࿩ slim.arg_scope() h_conv1 = slim.conv2d(x_image, 32, [5, 5], activation_fn=tf.nn.relu, weights_initializer=tf.truncated_normal_initializer(stddev=0.1),

    biases_initializer=tf.constant_initializer(0.1)) with slim.arg_scope([slim.conv2d], activation_fn=tf.nn.relu, weight_initializer=tf.truncated_normal_initializer(stddev=0.1), biases_initializer=tf.constant_initializer(0.1): h_conv1 = slim.conv2d(x_image, 32, [5, 5])
  10. 49.

    ஫ҙ͍ͨ͜͠ͱ with tf.variable_scope(‘darknet-53'): route_1, route_2, inputs = darknet53(inputs) with tf.variable_scope('yolo-v3'):

    with tf.variable_scope('detect_1'): route, inputs = _yolo_block(inputs, 512) • ఆ͚ٛͨͩ͠Ͱ͸
 άϥϑ͸ݟͮΒ͍ • είʔϓΛ
 ༻ҙ͠·͠ΐ͏ είʔϓແ είʔϓ༗
  11. 53.

    tf.print • ೖྗ͞ΕͨTensorͷ݁ՌΛɺ
 stdout΍ΒɺϩάϨϕϧͰग़ྗͯ͘͠ΕΔ • ਆ • ͪͳΈʹ΍΍͍͚͜͠Ͳɺtf.Print͸Ҿ਺΋ҧ͏͠ඇਪ঑Ͱ͢ • ͔͠͠ɺSessionฦ͞ͳ͍ͱ͍͚ͳ͍ͷͰɺϞσϧΛఆٛ͢Δͱ͜Ζʹ૊ΈࠐΉ࡞ۀ

    ʹϋϚͬͨ • ·ͨɺTensorflowͰఆٛͨ͠ม਺ͷத਎͸ݟΕ͕ͨɺ࣍ݩΛ֬ೝ͢ΔͨΊʹtf.shape ͱ͔ڬΉͱ݁Ռ͕ฦͬͯ͜ͳ͘ͳΔɻͳͥ • ʢ͕࣌ؒͳ͍ͷͰʣఘΊͨ tensor = tf.range(10) print_op = tf.print(tensor)
  12. 54.
  13. 57.