在adanet nn

时间:2019-07-19 05:10:27

标签: tensorflow keras adanet

我正在尝试使用Keras Dense图层制作基本的Adanet(tensorflow)目标示例,但检查点存在问题。 链接到示例: https://github.com/tensorflow/adanet/blob/master/adanet/examples/tutorials/adanet_objective.ipynb

您能帮忙解决此错误吗?

此代码可以正常工作:

def build_subnetwork(self,
                         features,
                         logits_dimension,
                         training,
                         iteration_step,
                         summary,
                         previous_ensemble=None):
        input_layer = tf.to_float(features[FEATURES_KEY])
        kernel_initializer = tf.glorot_uniform_initializer(seed=self._seed)
        last_layer = input_layer
        for _ in range(self._num_layers):
            last_layer = tf.layers.dense(
                last_layer,
                units=self._layer_size,
                activation=tf.nn.relu,
                kernel_initializer=kernel_initializer)
        logits = tf.layers.dense(
            last_layer,
            units=logits_dimension,
            kernel_initializer=kernel_initializer)
        persisted_tensors = {_NUM_LAYERS_KEY: tf.constant(self._num_layers)}
        return adanet.Subnetwork(
            last_layer=last_layer,
            logits=logits,
            complexity=self._measure_complexity(),
            persisted_tensors=persisted_tensors)

此代码出现错误:

def build_subnetwork(self,
                         features,
                         logits_dimension,
                         training,
                         iteration_step,
                         summary,
                         previous_ensemble=None):
        input_layer = tf.to_float(features[FEATURES_KEY])
        kernel_initializer = tf.glorot_uniform_initializer(seed=self._seed)
        last_layer = input_layer
        for _ in range(self._num_layers):
            last_layer = tf.keras.layers.Dense(
                units=64, activation="relu", kernel_initializer=kernel_initializer,
                use_bias=True, bias_initializer=kernel_initializer)(last_layer)
        logits = tf.keras.layers.Dense(
            units=2, activation=None, kernel_initializer=kernel_initializer,
            use_bias=True, bias_initializer=kernel_initializer)(last_layer)
        persisted_tensors = {_NUM_LAYERS_KEY: tf.constant(self._num_layers)}
        return adanet.Subnetwork(
            last_layer=last_layer,
            logits=logits,
            complexity=self._measure_complexity(),
            persisted_tensors=persisted_tensors)

错误:

  

2019-07-19 07:54:58.178313:W   tensorflow / core / framework / op_kernel.cc:1502] OP_REQUIRES在以下位置失败   save_restore_v2_ops.cc:184:找不到:密钥   找不到adanet / iteration_0 / subnetwork_t0_2_layer_dnn / dense / bias   检查点回溯(最近一次通话):文件   “ C:\ Python37 \ lib \ site-packages \ tensorflow \ python \ client \ session.py”,   1356行,_do_call中       返回fn(* args)文件“ C:\ Python37 \ lib \ site-packages \ tensorflow \ python \ client \ session.py”,   _run_fn中的第1341行       选项,feed_dict,fetch_list,target_list,run_metadata)文件“ C:\ Python37 \ lib \ site-packages \ tensorflow \ python \ client \ session.py”,   第1429行,在_call_tf_sessionrun中       run_metadata)

     

tensorflow.python.framework.errors_impl.NotFoundError:键   找不到adanet / iteration_0 / subnetwork_t0_2_layer_dnn / dense / bias   检查点[[{{node save / RestoreV2}}]]

0 个答案:

没有答案