赞
踩
- # 只返回最后一个时间步的输出
-
- from tensorflow.keras.models import Sequential
- from tensorflow.keras.layers import Embedding, SimpleRNN
-
- model = Sequential()
- model.add(Embedding(10000, 32))
- model.add(SimpleRNN(32))
- model.summary()
查了一下,当时用的numpy版本:
疑问:会不会是 numpy版本 太高了导致的?
于是,正好有个低版本的虚拟环境,其numpy版本为:
重新运行了上述代码,发现有Warning,但无伤大雅,可以运行:
- WARNING:tensorflow:From D:\QLDownload\AnacondaDon\envs\python37\lib\site-packages\tensorflow\python\keras\initializers.py:119: calling RandomUniform.__init__ (from tensorflow.python.ops.init_ops) with dtype is deprecated and will be removed in a future version.
- Instructions for updating:
- Call initializer instance with the dtype argument instead of passing it to the constructor
- WARNING:tensorflow:From D:\QLDownload\AnacondaDon\envs\python37\lib\site-packages\tensorflow\python\ops\init_ops.py:1251: calling VarianceScaling.__init__ (from tensorflow.python.ops.init_ops) with dtype is deprecated and will be removed in a future version.
- Instructions for updating:
- Call initializer instance with the dtype argument instead of passing it to the constructor
- Model: "sequential"
- _________________________________________________________________
- Layer (type) Output Shape Param #
- =================================================================
- embedding (Embedding) (None, None, 32) 320000
- _________________________________________________________________
- simple_rnn (SimpleRNN) (None, 32) 2080
- =================================================================
- Total params: 322,080
- Trainable params: 322,080
- Non-trainable params: 0
- _________________________________________________________________

BTW,虚拟环境的其他配置为:
scipy==1.3.0
Keras==2.2.4
numpy==1.16.4
networkx==2.1
tensorflow_gpu==1.14.0
scikit_learn==0.21.2
tensorflow==1.14.0
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。