我正在研究如何在图层中设置自定义权重。
下面是我使用的代码
batch_size = 64
input_dim = 12
units = 64
output_size = 1 # labels are from 0 to 9
# Build the RNN model
def build_model(allow_cudnn_kernel=True):
lstm_layer = keras.layers.RNN(
keras.layers.LSTMCell(units), input_shape=(None, input_dim))
model = keras.models.Sequential(
[
lstm_layer,
keras.layers.BatchNormalization(),
keras.layers.Dense(output_size),
]
)
return model
model = build_model()
model.compile(
loss=keras.losses.MeanSquaredError(),
optimizer="Adam",
metrics=["accuracy"],
)
model.fit(
x_train, y_train, validation_data=(x_val, y_val), batch_size=batch_size, epochs=15
)
Run Code Online (Sandbox Code Playgroud)
模型概要
谁能帮我如何在上面的代码中设置权重?提前致谢。
我使用下面的代码阅读文本格式,
f = open("document.txt", "r+", encoding='utf-8-sig')
f.read()
Run Code Online (Sandbox Code Playgroud)
但类型f是_io.TextIOWrapper. 但我需要输入字符串才能继续。
请帮我转换 _io.TextIOWrapper为字符串。
我尝试使用查看我的 CSV 文件
!head {train_file_path}
Run Code Online (Sandbox Code Playgroud)
在 jupyter 笔记本中。但它会引发错误
'head' is not recognized as an internal or external command,
operable program or batch file.
Run Code Online (Sandbox Code Playgroud)
!head{}在Colab中有效,但在 Jupyter Notebook 中无效。
请帮助我,伙计们。提前致谢