Ich verwende Windows 10, Python 3.5 und Tensorflow 1.1.0. Ich habe das folgende Skript:Keras 2.x - Get Gewichte der Ebene
import tensorflow as tf
import tensorflow.contrib.keras.api.keras.backend as K
from tensorflow.contrib.keras.api.keras.layers import Dense
tf.reset_default_graph()
init = tf.global_variables_initializer()
sess = tf.Session()
K.set_session(sess) # Keras will use this sesssion to initialize all variables
input_x = tf.placeholder(tf.float32, [None, 10], name='input_x')
dense1 = Dense(10, activation='relu')(input_x)
sess.run(init)
dense1.get_weights()
Ich erhalte den Fehler: AttributeError: 'Tensor' object has no attribute 'weights'
Was mache ich falsch, und wie bekomme ich die Gewichte von dense1
? Ich habe this und this SO Post, aber ich kann es immer noch nicht funktionieren.
Was ist der richtige Weg, dies zu tun, wenn ich mehrere Schichten wollen? I.e. Gibt es einen besseren Weg als 'y = dichte2 (dichte1 (input_x))' –
Vielen Dank für diese Erklärung. Klarheit vorausgesetzt. –