I’ve followed the tutorial for using tensorflow and installed keras-rl alongside it in the virtualenv
But I encountered the following problems with the import…
2018-02-14 21:44:03,954 [Thread-46 ] [hbp_nrp_cles] [ERROR] Error in Transfer Function (Runtime): local variable 'Sequential' referenced before assignment
Traceback (most recent call last):
File "/home/akshay/Dokumente/NRP/CLE/hbp_nrp_cle/hbp_nrp_cle/tf_framework/_TransferFunction.py", line 200, in run
return self._func(*self._params)
File "<string>", line 46, in init_DRLagent
UnboundLocalError: local variable 'Sequential' referenced before assignment
Using TensorFlow backend.
2018-02-14 21:44:05,848 [Thread-46 ] [hbp_nrp_cles] [CRITICAL] Unhandled exception of type <type 'exceptions.RuntimeError'>: module compiled against API version 0xb but this version of numpy is 0xa
2018-02-14 21:44:05,849 [Thread-46 ] [hbp_nrp_cles] [ERROR] None
Traceback (most recent call last):
File "/home/akshay/.opt/kerasrl_venv/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 37, in <module>
from tensorflow.python import pywrap_dlopen_global_flags
ImportError: cannot import name pywrap_dlopen_global_flags
2018-02-14 21:44:05,850 [Thread-46 ] [hbp_nrp_cles] [CRITICAL] Unhandled exception of type <type 'exceptions.RuntimeError'>: module compiled against API version 0xb but this version of numpy is 0xa
2018-02-14 21:44:05,850 [Thread-46 ] [hbp_nrp_cles] [ERROR] None
Traceback (most recent call last):
File "/home/akshay/.opt/kerasrl_venv/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 37, in <module>
from tensorflow.python import pywrap_dlopen_global_flags
ImportError: cannot import name pywrap_dlopen_global_flags
[libprotobuf FATAL external/protobuf_archive/src/google/protobuf/stubs/common.cc:68] This program requires version 3.5.0 of the Protocol Buffer runtime library, but the installed version is 3.4.0. Please update your library. If you compiled the program yourself, make sure that your headers are from the same version of Protocol Buffers as your link-time library. (Version verification failed in "google/protobuf/descriptor.pb.cc".)
terminate called after throwing an instance of 'google::protobuf::FatalException'
using the following TF, which is pretty much the same as the TF in the advanced tensorflow tutorial for object detection
# internal keras-rl agent to persist
@nrp.MapVariable("agent", initial_value=None, scope=nrp.GLOBAL)
@nrp.MapVariable("bridge", initial_value=None, scope=nrp.GLOBAL)
# subscribe to images from the robot
@nrp.MapRobotSubscriber("camera", Topic('/husky/camera', sensor_msgs.msg.Image))
@nrp.MapRobotSubscriber("vel", Topic('/husky/cmd_vel', geometry_msgs.msg.Twist))
@nrp.Robot2Neuron()
def init_DRLagent(t, agent, bridge, camera, vel):
# initialize the keras-rl agent
if agent.value is None and camera.value is not None:
print("INITIALIZING AGENT")
try:
# import keras-rl in NRP through virtual env
import site, os
site.addsitedir(os.path.expanduser('/home/akshay/.opt/kerasrl_venv/lib/python2.7/site-packages'))
from keras.models import Model
from keras.models import Sequential
from keras.layers import Dense
from keras.layers import Activation
from keras.layers import Flatten
from keras.layers import Input
from keras.layers import concatenate
from keras.optimizers import Adam
from keras.optimizers import RMSprop
from rl.agents import DDPGAgent
from rl.memory import SequentialMemory
from rl.random import OrnsteinUhlenbeckProcess
except:
clientLogger.info("Unable to import keras-rl, did you change the path in the transfer function?")
raise
import numpy as np
# OpenCV bridge for ROS <-> CV image conversion
from cv_bridge import CvBridge
bridge.value = CvBridge()
# convert the ROS image to an OpenCV image and Numpy array
cv_image = bridge.value.imgmsg_to_cv2(camera.value, "rgb8")
numpy_image = np.expand_dims(cv_image, axis=0)
obs_shape = numpy_image.shape
nb_actions = 2
# create the nets for rl agent
# actor net
#from keras.models import Sequential
actor = Sequential()
actor.add(Flatten(input_shape=(1,) + obs_shape))#camera.value.shape))
actor.add(Dense(32))
actor.add(Activation('relu'))
actor.add(Dense(32))
actor.add(Activation('relu'))
actor.add(Dense(32))
actor.add(Activation('relu'))
actor.add(Dense(nb_actions))
actor.add(Activation('sigmoid'))
print(actor.summary())
...
Any help would be appreciated.