【发布时间】:2021-03-08 00:14:20
【问题描述】:
我有一个基于 GRU 的模型。我已将其转换为 tensorflow js 。在 tfjs 中加载它时出现错误
未处理的拒绝(错误):GRUCell 不支持将 reset_after 参数设置为 true。
我已经附上了相应的 json 。请指教
{"format": "layers-model", "generatedBy": "keras v2.4.0", "convertedBy": "TensorFlow.js Converter v2.7.0", "modelTopology": {"keras_version": "2.4 .0”,“后端”:“tensorflow”,“model_config”:{“class_name”:“Sequential”,“config”:{“name”:“sequential”,“layers”:[{“class_name”:“InputLayer ", "config": {"batch_input_shape": [null, 48, 64], "dtype": "float32", "sparse": false, "ragged": false, "name": "input_1"}}, { “class_name”:“LayerNormalization”,“config”:{“name”:“layer_normalization”,“trainable”:true,“dtype”:“float32”,“axis”:[2],“epsilon”:0.001,“中心”:真,“规模”:真,“beta_initializer”:{“class_name”:“Zeros”,“config”:{}},“gamma_initializer”:{“class_name”:“Ones”,“config”:{ }},“beta_regularizer”:null,“gamma_regularizer”:null,“beta_constraint”:null,“gamma_constraint”:null}},{“class_name”:“Conv1D”,“config”:{“name”:“conv1d” ,“可训练”:true,“dtype”:“float32”,“filters”:32,“kernel_size”:[3],“strides”:[1],“padding”:“valid”,“data_format “:“channels_last”,“dilation_rate”:[1],“groups”:1,“activation”:“relu”,“use_bias”:true,“kernel_initializer”:{“class_name”:“GlorotUniform”,“config” :{“seed”:null}},“bias_initializer”:{“class_name”:“Zeros”,“config”:{}},“kernel_regularizer”:null,“bias_regularizer”:null,“activity_regularizer”:null,“ kernel_constraint”:null,“bias_constraint”:null}},{“class_name”:“BatchNormalization”,“config”:{“name”:“batch_normalization”,“trainable”:true,“dtype”:“float32”,“轴”:[2],“动量”:0.99,“epsilon”:0.001,“中心”:真,“规模”:真,“beta_initializer”:{“class_name”:“Zeros”,“config”:{} },“gamma_initializer”:{“class_name”:“Ones”,“config”:{}},“moving_mean_initializer”:{“class_name”:“Zeros”,“config”:{}},“moving_variance_initializer”:{“ class_name": "Ones", "config": {}}, "beta_regularizer": null, "gamma_regularizer": null, "beta_constraint": null, "gamma_constraint": null}}, {"class_name": "MaxPooling1D", “配置”:{“名称”:“max_pooling1d”,“tr ainable”:true,“dtype”:“float32”,“strides”:[3],“pool_size”:[3],“padding”:“valid”,“data_format”:“channels_last”}},{“class_name “:“Conv1D”,“config”:{“name”:“conv1d_1”,“trainable”:true,“dtype”:“float32”,“filters”:32,“kernel_size”:[3],“strides” :[1],“填充”:“有效”,“data_format”:“channels_last”,“dilation_rate”:[1],“组”:1,“激活”:“relu”,“use_bias”:true,“ kernel_initializer”:{“class_name”:“GlorotUniform”,“config”:{“seed”:null}},“bias_initializer”:{“class_name”:“Zeros”,“config”:{}},“kernel_regularizer”: null,“bias_regularizer”:null,“activity_regularizer”:null,“kernel_constraint”:null,“bias_constraint”:null}},{“class_name”:“Dropout”,“config”:{“name”:“dropout”, “可训练”:true,“dtype”:“float32”,“rate”:0.25,“noise_shape”:null,“seed”:null}},{“class_name”:“GRU”,“config”:{“name “:“gru”,“可训练”:真,“dtype”:“float32”,“return_sequences”:真,“return_state”:假,“go_backwards”:假,“有状态”:假,“ unroll": false, "time_major": false, "units": 40, "activation": "tanh", "recurrent_activation": "sigmoid", "use_bias": true, "kernel_initializer": {"class_name": "GlorotUniform ", "config": {"seed": null}}, "recurrent_initializer": {"class_name": "Orthogonal", "config": {"gain": 1.0, "seed": null}}, "bias_initializer" :{“class_name”:“Zeros”,“config”:{}},“kernel_regularizer”:null,“recurrent_regularizer”:null,“bias_regularizer”:null,“activity_regularizer”:null,“kernel_constraint”:null,“recurrent_constraint ": null, "bias_constraint": null, "dropout": 0.0, "recurrent_dropout": 0.0, "implementation": 2, "reset_after": true}}, {"class_name": "GRU", "config": { “名称”:“gru_1”,“可训练”:真,“dtype”:“float32”,“return_sequences”:假,“return_state”:假,“go_backwards”:假,“有状态”:假,“展开”: false,“time_major”:false,“units”:40,“activation”:“tanh”,“recurrent_activation”:“sigmoid”,“use_bias”:true,“kernel_initializer”:{“class_name”:“GlorotUniform ", "config": {"seed": null}}, "recurrent_initializer": {"class_name": "Orthogonal", "config": {"gain": 1.0, "seed": null}}, "bias_initializer" :{“class_name”:“Zeros”,“config”:{}},“kernel_regularizer”:null,“recurrent_regularizer”:null,“bias_regularizer”:null,“activity_regularizer”:null,“kernel_constraint”:null,“recurrent_constraint ": null, "bias_constraint": null, "dropout": 0.0, "recurrent_dropout": 0.0, "implementation": 2, "reset_after": true}}, {"class_name": "Flatten", "config": { “名称”:“扁平化”,“可训练”:真,“dtype”:“float32”,“data_format”:“channels_last”}},{“class_name”:“密集”,“config”:{“name”: “密集”,“可训练”:真,“dtype”:“float32”,“单位”:100,“激活”:“relu”,“use_bias”:真,“kernel_initializer”:{“class_name”:“GlorotUniform” ,“配置”:{“种子”:null}},“bias_initializer”:{“class_name”:“Zeros”,“config”:{}},“kernel_regularizer”:null,“bias_regularizer”:null,“activity_regularizer” :空,“kernel_constraint”:空,“bias_con应变“:null}},{“class_name”:“Dropout”,“config”:{“name”:“dropout_1”,“trainable”:true,“dtype”:“float32”,“rate”:0.25,“噪声形状”:空,“种子”:空}},{“类名”:“密集”,“配置”:{“名称”:“密集_1”,“可训练”:真,“dtype”:“float32”,“单位”:2,“激活”:“线性”,“use_bias”:true,“kernel_initializer”:{“class_name”:“GlorotUniform”,“config”:{“seed”:null}},“bias_initializer”:{ “class_name”:“Zeros”,“config”:{}},“kernel_regularizer”:null,“bias_regularizer”:null,“activity_regularizer”:null,“kernel_constraint”:null,“bias_constraint”:null}}]}} , "training_config": {"loss": {"class_name": "SparseCategoricalCrossentropy", "config": {"reduction": "auto", "name": "sparse_categorical_crossentropy", "from_logits": true}}, "metrics “:[“准确度”],“weighted_metrics”:null,“loss_weights”:null,“optimizer_config”:{“class_name”:“Adam”,“config”:{“name”:“Adam”,“learning_rate”: 0.0010000000474974513,“衰减”:0.0,“beta_1”:0.8999999761581421,“beta _2": 0.9990000128746033, "epsilon": 1e-07, "amsgrad": false}}}}, "weightsManifest": [{"paths": ["group1-shard1of1.bin"], "weights": [{"名称”:“batch_normalization/gamma”,“shape”:[32],“dtype”:“float32”},{“name”:“batch_normalization/beta”,“shape”:[32],“dtype”:“ float32"},{"name":"batch_normalization/moving_mean","shape":[32],"dtype":"float32"},{"name":"batch_normalization/moving_variance","shape":[32] , "dtype": "float32"}, {"name": "conv1d/kernel", "shape": [3, 64, 32], "dtype": "float32"}, {"name": "conv1d/偏差”,“形状”:[32],“dtype”:“float32”},{“名称”:“conv1d_1/kernel”,“形状”:[3,32,32],“dtype”:“float32” }, {"name": "conv1d_1/bias", "shape": [32], "dtype": "float32"}, {"name": "dense/kernel", "shape": [40, 100] ,“dtype”:“float32”},{“name”:“dense/bias”,“shape”:[100],“dtype”:“float32”},{“name”:“dense_1/kernel”,“ shape”:[100, 2],“dtype”:“float32”},{“name”:“dense_1/bias”,“shape”:[2],“dtype”:“float32”},{“name” :“gru/gru_cell/内核”,“形状”: [32, 120], "dtype": "float32"}, {"name": "gru/gru_cell/recurrent_kernel", "shape": [40, 120], "dtype": "float32"}, {"name ": "gru/gru_cell/bias", "shape": [2, 120], "dtype": "float32"}, {"name": "gru_1/gru_cell_1/kernel", "shape": [40, 120 ],“dtype”:“float32”},{“name”:“gru_1/gru_cell_1/recurrent_kernel”,“shape”:[40, 120],“dtype”:“float32”},{“name”:“gru_1 /gru_cell_1/bias", "shape": [2, 120], "dtype": "float32"}, {"name": "layer_normalization/gamma", "shape": [64], "dtype": "float32 "}, {"name": "layer_normalization/beta", "shape": [64], "dtype": "float32"}]}]}
【问题讨论】:
-
也许你可以在github上打开一个问题
-
你找到解决这个问题的方法了吗?我目前有这个问题,找不到任何东西
-
@Macro ,不,我没有得到解决方案。但是有些地方我发现基于 python 的新 gru 单元与基于 js 的单元不同。 tfjs 中尚未提供最新更改
标签: javascript tensorflow tensorflow.js