本文整理汇总了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):