问题就是由 deconv 函数中的 tf.shape 和 tf.pack 这两个操作引起的,在 PC 版代码中,为了简洁,是基于这两个操作,自动计算出 upsampled_shape,修改过后,则是要求调用者用 hard coding 的方式设置对应的 upsampled_shape。 裁剪 TensorFlow TensorFlow 是一个很庞大的框架,对于手机来说,它占用的体积是比较大的,所以需要尽量的缩减 TensorFlow 库占用的体积。 其实在解决前面遇到的那个 crash 问题的时候,已经指明了一种裁剪的思路,既然 mobile 版的 TensorFlow 本来就是 PC 版的一个子集,那就意味着可以根据具体的需求,让这个子集变得更小,这也就达到了裁剪的目的。具体来说,就是修改 TensorFlow 源码中的 tensorflow/tensorflow/contrib/makefile/tf_op_files.txt 文件,只保留使用到了的模块。针对 HED 网络,原有的 200 多个模块裁剪到只剩 46 个,裁剪过后的 tf_op_files.txt 文件如下: tensorflow/core/kernels/xent_op.cc tensorflow/core/kernels/where_op.cc tensorflow/core/kernels/unpack_op.cc tensorflow/core/kernels/transpose_op.cc tensorflow/core/kernels/transpose_functor_cpu.cc tensorflow/core/kernels/tensor_array_ops.cc tensorflow/core/kernels/tensor_array.cc tensorflow/core/kernels/split_op.cc tensorflow/core/kernels/split_v_op.cc tensorflow/core/kernels/split_lib_cpu.cc tensorflow/core/kernels/shape_ops.cc tensorflow/core/kernels/session_ops.cc tensorflow/core/kernels/sendrecv_ops.cc tensorflow/core/kernels/reverse_op.cc tensorflow/core/kernels/reshape_op.cc tensorflow/core/kernels/relu_op.cc tensorflow/core/kernels/pooling_ops_common.cc tensorflow/core/kernels/pack_op.cc tensorflow/core/kernels/ops_util.cc tensorflow/core/kernels/no_op.cc tensorflow/core/kernels/maxpooling_op.cc tensorflow/core/kernels/matmul_op.cc tensorflow/core/kernels/immutable_constant_op.cc tensorflow/core/kernels/identity_op.cc tensorflow/core/kernels/gather_op.cc tensorflow/core/kernels/gather_functor.cc tensorflow/core/kernels/fill_functor.cc tensorflow/core/kernels/dense_update_ops.cc tensorflow/core/kernels/deep_conv2d.cc tensorflow/core/kernels/xsmm_conv2d.cc tensorflow/core/kernels/conv_ops_using_gemm.cc tensorflow/core/kernels/conv_ops_fused.cc tensorflow/core/kernels/conv_ops.cc tensorflow/core/kernels/conv_grad_filter_ops.cc tensorflow/core/kernels/conv_grad_input_ops.cc tensorflow/core/kernels/conv_grad_ops.cc tensorflow/core/kernels/constant_op.cc tensorflow/core/kernels/concat_op.cc tensorflow/core/kernels/concat_lib_cpu.cc tensorflow/core/kernels/bias_op.cc tensorflow/core/ops/sendrecv_ops.cc tensorflow/core/ops/no_op.cc tensorflow/core/ops/nn_ops.cc tensorflow/core/ops/nn_grad.cc tensorflow/core/ops/array_ops.cc tensorflow/core/ops/array_grad.cc (责任编辑:本港台直播) |