检查失败:NDIMS == dims()(1 vs.2)从2维张量求1维张量

时间:2019-07-19 18:31:07

标签: python linux python-3.x tensorflow

我从强化学习开始,希望使用体育馆来创造自己的环境。我找到了stable_baseline,我想使用不同的代理来查看哪种代理可以更好地解决我的环境。

我已经下载了所有软件包,但是却发现了错误。我尝试了许多版本的tensorflow,包括(1.5,1.11,1.12,1.13,1.14),但我总是收到此错误,并且我还没有找到调试它的方法。我添加了我的简单代码,也许有人看到了我看不到的错误。


import gym
import gym_luminaire

from stable_baselines import A2C
from stable_baselines.common.vec_env import DummyVecEnv

env=gym.make("luminaire-v0",metrics_number=3,batch_size=1)
dummy_env = DummyVecEnv([lambda: env])

model = A2C("MlpPolicy", dummy_env, learning_rate=1e-3,verbose=1)
# Train the agent
model.learn(total_timesteps=int(2e5))

observations = env.reset()
for i in range(1000):
    action, _states = model.predict(observations)
    obs, rewards, done, _ = env.step(action)

    if done==True:
        observations = env.reset()
Check failed: NDIMS == dims() (1 vs. 2)Asking for tensor of 1 dimensions from a tensor of 2 dimensions
[fglt-KVM:12941] *** Process received signal ***
[fglt-KVM:12941] Signal: Aborted (6)
[fglt-KVM:12941] Signal code:  (-6)
[fglt-KVM:12941] [ 0] /lib/x86_64-linux-gnu/libc.so.6(+0x3ef20)[0x7f433ace3f20]
[fglt-KVM:12941] [ 1] /lib/x86_64-linux-gnu/libc.so.6(gsignal+0xc7)[0x7f433ace3e97]
[fglt-KVM:12941] [ 2] /lib/x86_64-linux-gnu/libc.so.6(abort+0x141)[0x7f433ace5801]
[fglt-KVM:12941] [ 3] /home/fglt/.local/lib/python3.6/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so(+0x35fb664)[0x7f42ce82e664]
[fglt-KVM:12941] [ 4] /home/fglt/.local/lib/python3.6/site-packages/tensorflow/python/../libtensorflow_framework.so(+0x3f64cd)[0x7f42caa244cd]
[fglt-KVM:12941] [ 5] /home/fglt/.local/lib/python3.6/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so(_ZNK10tensorflow6Tensor6tensorIiLm1EEENS_6TTypesIT_XT0_ElE11ConstTensorEv+0x27)[0x7f42cc7de897]
[fglt-KVM:12941] [ 6] /home/fglt/.local/lib/python3.6/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so(+0x337a217)[0x7f42ce5ad217]
[fglt-KVM:12941] [ 7] /home/fglt/.local/lib/python3.6/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so(+0x337aebb)[0x7f42ce5adebb]
[fglt-KVM:12941] [ 8] /home/fglt/.local/lib/python3.6/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so(_ZNSt17_Function_handlerIFN10tensorflow6StatusEPNS0_15shape_inference16InferenceContextEEPS5_E9_M_invokeERKSt9_Any_dataS4_+0x14)[0x7f42ce8301a4]
[fglt-KVM:12941] [ 9] /home/fglt/.local/lib/python3.6/site-packages/tensorflow/python/../libtensorflow_framework.so(_ZN10tensorflow15shape_inference16InferenceContext3RunERKSt8functionIFNS_6StatusEPS1_EE+0x2d)[0x7f42caa03b4d]
[fglt-KVM:12941] [10] /home/fglt/.local/lib/python3.6/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so(+0x122e6e3)[0x7f42cc4616e3]
[fglt-KVM:12941] [11] /home/fglt/.local/lib/python3.6/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so(_ZN10tensorflow4swig20RunCppShapeInferenceEiRKSsRKSt6vectorISsSaISsEEP7_objectS7_P9TF_Status+0x16f)[0x7f42cc4622df]
[fglt-KVM:12941] [12] /home/fglt/.local/lib/python3.6/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so(+0x120c06c)[0x7f42cc43f06c]
[fglt-KVM:12941] [13] /usr/bin/python3[0x4f858d]
[fglt-KVM:12941] [14] /usr/bin/python3(_PyEval_EvalFrameDefault+0x467)[0x4f98c7]
[fglt-KVM:12941] [15] /usr/bin/python3[0x4f6128]
[fglt-KVM:12941] [16] /usr/bin/python3[0x4f7d60]
[fglt-KVM:12941] [17] /usr/bin/python3[0x4f876d]
[fglt-KVM:12941] [18] /usr/bin/python3(_PyEval_EvalFrameDefault+0x467)[0x4f98c7]
[fglt-KVM:12941] [19] /usr/bin/python3[0x4f6128]
[fglt-KVM:12941] [20] /usr/bin/python3[0x4f7d60]
[fglt-KVM:12941] [21] /usr/bin/python3[0x4f876d]
[fglt-KVM:12941] [22] /usr/bin/python3(_PyEval_EvalFrameDefault+0x1260)[0x4fa6c0]
[fglt-KVM:12941] [23] /usr/bin/python3[0x4f6128]
[fglt-KVM:12941] [24] /usr/bin/python3[0x4f7d60]
[fglt-KVM:12941] [25] /usr/bin/python3[0x4f876d]
[fglt-KVM:12941] [26] /usr/bin/python3(_PyEval_EvalFrameDefault+0x467)[0x4f98c7]
[fglt-KVM:12941] [27] /usr/bin/python3[0x4f7a28]
[fglt-KVM:12941] [28] /usr/bin/python3[0x4f876d]
[fglt-KVM:12941] [29] /usr/bin/python3(_PyEval_EvalFrameDefault+0x467)[0x4f98c7]
[fglt-KVM:12941] *** End of error message ***
Aborted (core dumped)

有什么想法吗?以及我该如何调试呢?

0 个答案:

没有答案