重写facenet出现的问题:

来源:互联网 发布:沪深300股指期货 知乎 编辑:程序博客网 时间:2024/06/04 18:18

重写facenet出现的问题:

1. Shape must be rank 0 but is rank 1 for ‘SGD/GradientDescent/update_conv1_3/kernel/ApplyGradientDescent’ (op: ‘ApplyGradientDescent’) with input shapes: [3,3,3,32], [1], [3,3,3,32].

learning_rate  = tf.placeholder(shape=(1,), dtype=tf.float32, name='learning_rate')optimizer = tf.train.GradientDescentOptimizer(learning_rate).minimize(total_loss)

上述问题出现的原因是learning_rate 为tensor, 将learning_rate 改为scalar 常数值即可

2. Input 0 is incompatible with layer flatten_1: expected min_ndim=3, found ndim=2

当keras域tensorflow混用时可能出现这种情况

3. W tensorflow/core/framework/op_kernel.cc:1192] Invalid argument: You must feed a value for placeholder tensor ‘conv1_bn/keras_learning_phase’ with dtype bool

当keras域tensorflow混用时可能出现这种情况

[[Node: conv1_bn/keras_learning_phase = Placeholderdtype=DT_BOOL, shape=, _device=”/job:localhost/replica:0/task:0/gpu:0”]]
我的最终解决方案为如下

K.set_learning_phase(1)

下面为其他参考方案:(如果后面内容为 dtype=DT_UINT8 )

K._LEARNING_PHASE = tf.constant(0) # try with 1

change it to its below: (add K.learning_phase())

pred = K.function([model.input], [model.output])pred = K.function([model.input, K.learning_phase()], [model.output])
原创粉丝点击