'AdamOptimizer' object has no attribute 'minimize'
时间: 2023-06-21 07:18:30 浏览: 455
This error message usually occurs when you are trying to call the `minimize` method on an `AdamOptimizer` object, but the object does not have a `minimize` method.
In TensorFlow, the `minimize` method is typically called on a `tf.train.Optimizer` object, which is a parent class for all the optimizers, including `AdamOptimizer`.
To fix this error, you should create a `tf.train.Optimizer` object using the `tf.train.AdamOptimizer()` method, and then call the `minimize` method on that object. Here is an example:
```
optimizer = tf.train.AdamOptimizer(learning_rate=0.001)
train_op = optimizer.minimize(loss)
```
In this example, the `optimizer` object is created using the `tf.train.AdamOptimizer()` method with a specified learning rate of 0.001. The `minimize` method is then called on the `optimizer` object to create the `train_op` operation, which performs the parameter updates during training.
阅读全文