小编BSP*_*BSP的帖子

如何在图层中设置自定义权重?

我正在研究如何在图层中设置自定义权重。

下面是我使用的代码

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)

模型概要

在此输入图像描述

谁能帮我如何在上面的代码中设置权重?提前致谢。

neural-network deep-learning keras tensorflow

6
推荐指数
1
解决办法
2862
查看次数

如何将 _io.TextIOWrapper 转换为字符串?

我使用下面的代码阅读文本格式,

f = open("document.txt", "r+", encoding='utf-8-sig')
f.read()
Run Code Online (Sandbox Code Playgroud)

但类型f_io.TextIOWrapper. 但我需要输入字符串才能继续。

请帮我转换 _io.TextIOWrapper为字符串。

python string file

6
推荐指数
2
解决办法
7311
查看次数

Jupyter Notebook:“head”未被识别为内部或外部命令、可操作程序或批处理文件

我尝试使用查看我的 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 中无效。

请帮助我,伙计们。提前致谢

python deep-learning tensorflow jupyter-notebook

5
推荐指数
1
解决办法
1万
查看次数