本文整理匯總了Python中keras.layers.Dense.set_input方法的典型用法代碼示例。如果您正苦於以下問題:Python Dense.set_input方法的具體用法?Python Dense.set_input怎麽用?Python Dense.set_input使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類keras.layers.Dense
的用法示例。
在下文中一共展示了Dense.set_input方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: Sequential
# 需要導入模塊: from keras.layers import Dense [as 別名]
# 或者: from keras.layers.Dense import set_input [as 別名]
###Test parameters:
sample_width = 5
nb_train_samples = 20000
nb_test_samples = 1000
###Making the layers:
labels = tf.placeholder(tf.float32, shape=(None,1))
features = tf.placeholder(tf.float32, shape=(None,sample_width))
from keras.models import Sequential
from keras.layers import Dense
import random
model = Sequential()
first_layer = Dense(20, activation='sigmoid', input_shape=(None,sample_width))
first_layer.set_input(features)
model.add(first_layer)
model.add(Dense(1, activation='sigmoid'))
output_layer = model.output
###making training data & test data:
train_features = np.random.randn(nb_train_samples, sample_width)
train_labels = np.zeros(nb_train_samples).reshape(nb_train_samples, 1)
test_features = np.random.randn(nb_test_samples, sample_width)
test_labels = np.zeros(nb_test_samples).reshape(nb_test_samples, 1)
train_ones = 0
test_ones = 0
for i in range(nb_train_samples):