Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Error converting shape to a TensorShape: int() argument must be a string, a bytes-like object or a number, not 'tuple' #3

Open
ronseg1 opened this issue Oct 10, 2018 · 5 comments

Comments

@ronseg1
Copy link

ronseg1 commented Oct 10, 2018

Canceled

@kinwafung
Copy link

got the same problem. can I get some help pls ?

@JeancarloBarrios
Copy link

Im not sure if this is the reason why but i downgraded the gym version to 0.9.4 and it worked i had 0.10.8 before

@S0AndS0
Copy link

S0AndS0 commented Mar 7, 2019

For anyone else running into issues juggling versions of various dependencies causing odd errors, the TensorFlow pip docs have hints for not messing things up on system wide or user environment levels.

After following up to step two in linked guide one can...

# Clone the source and cd there, eg
git clone https://github.com/llSourcell/Q-Learning-for-Trading.git
cd Q-Learning-for-Trading

# Make a virtual environment specific to cloned project
virtualenv --system-site-packages -p python2.7 ./venv

## Note I used `python3.5` instead as there was only one
##  package with a specific version, and things _seemed_
##  to work

# Change shell to that of the virtual environment
source ./venv/bin/activate

# Install packages within virtual environment while
# ignoring system or user level pre-existing packages
pip install -r requirements.txt --ignore-installed

Side note, might be good to check SO-QA on forcing pip installations

To exit the (venv) prefixed shell deactivate maybe issued

Prior to running the project's code will require...

cd Q-Learning-for-Trading
source ./venv/bin/activate

... but I consider that low cost when weighed against sorting out how to install every developer's project dependencies without conflicts.

@init-22
Copy link

init-22 commented May 22, 2019

Hey Guys, Ive got this problem and I solved it by converting the tuple n_obs which was (7,2) (in model.py file) in and then multiplying it to pass it to the input_dim of keras which expects the input as 7*2
take a look at my code in model.py file ...
def mlp(n_obs, n_action, n_hidden_layer=1, n_neuron_per_layer=32,
activation='relu', loss='mse'):

n_obs = np.array(n_obs)
n_obs = n_obs[0]*n_obs[1]

""" A multi-layer perceptron """
model = Sequential()
print(type(n_neuron_per_layer),type(n_obs),type(activation) )
model.add(Dense(n_neuron_per_layer, input_dim=n_obs, activation=activation))

@AntoineMath
Copy link

AntoineMath commented Aug 24, 2019

@IsaacPatole more elegant way :
in run.py , line 36:
replace
state_size = env.observation_space.shape
by
state_size = np.prod(env.observation_space.shape)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants