我正在使用 Keras 训练以下模型,如图所示:
model = tf.keras.models.Sequential([tf.keras.layers.Conv2D(64, (3,3), activation='relu', input_shape=(256, 256, 3)),
tf.keras.layers.MaxPooling2D(2, 2),
tf.keras.layers.Conv2D(64, (3,3), activation='relu'),
tf.keras.layers.MaxPooling2D(2,2),
tf.keras.layers.Flatten(),
tf.keras.layers.Dense(12, activation=tf.nn.relu),
tf.keras.layers.Dense(10, activation=tf.nn.relu),
tf.keras.layers.Dense(1, activation=tf.sigmoid)])
model.compile(optimizer = tf.keras.optimizers.Adam(learning_rate=0.0001),loss,'binary_crossentropy, metrics=['accuracy'])
model.fit(X_train, y_train, epochs=20)
Run Code Online (Sandbox Code Playgroud)
运行以下命令以检查测试集的准确性时
model.evaluate(X_test,y_test)
Run Code Online (Sandbox Code Playgroud)
我收到以下警告:
警告:tensorflow:最近 13 次调用 <function Model.make_test_function..test_function at 0x000001E51AA92AE8> 中的 5 次触发了 tf.function 回溯。跟踪是昂贵的,过多的跟踪可能是由于 (1) 在循环中重复创建 @tf.function,(2) 传递具有不同形状的张量,(3) 传递 Python 对象而不是张量。对于(1),请在循环之外定义您的@tf.function。对于 (2),@tf.function 有 Experiment_relax_shapes=True 选项,可以放宽参数形状,避免不必要的回溯。对于(3),请参考https://www.tensorflow.org/tutorials/customization/performance#python_or_tensor_args和https://www.tensorflow.org/api_docs/python/tf/function更多细节。2/2 [==============================] - 0s 94ms/步 - 损失:0.6660 - 准确度:0.5909
你能帮我理解为什么吗?