如果您写:
dense1 = Dense(10, activation='relu')(input_x)
然后
dense1不是图层,而是图层的输出。该层是
Dense(10, activation='relu')
所以看来您的意思是:
dense1 = Dense(10, activation='relu')y = dense1(input_x)
这是完整的代码段:
import tensorflow as tffrom tensorflow.contrib.keras import layersinput_x = tf.placeholder(tf.float32, [None, 10], name='input_x') dense1 = layers.Dense(10, activation='relu')y = dense1(input_x)weights = dense1.get_weights()



