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

AttributeError: 'NoneType' object has no attribute 'run' #18

Closed
blueboy09 opened this issue Feb 19, 2018 · 6 comments
Closed

AttributeError: 'NoneType' object has no attribute 'run' #18

blueboy09 opened this issue Feb 19, 2018 · 6 comments

Comments

@blueboy09
Copy link

blueboy09 commented Feb 19, 2018

I just run the "python hypersearch.py" directly and get the following error. Actually, I find that "self.monitored_session.run" have repeated many times and finally it got a None. I am not familiar with tensorforce and do not know what happened. Any help is appreciated.


Traceback (most recent call last):
  File "hypersearch.py", line 772, in <module>
    main()
  File "hypersearch.py", line 768, in main
    y_list=Y
  File "/home/RL/tforce_btc_trader/gp.py", line 193, in bayesian_optimisation2
    y_list.append(loss_fn(params))
  File "hypersearch.py", line 719, in loss_fn
    reward = hsearch.execute(vec2hypers(params))
  File "hypersearch.py", line 547, in execute
    env.train_and_test(agent, self.cli_args.n_steps, self.cli_args.n_tests, -1)
  File "/home/RL/tforce_btc_trader/btc_env.py", line 487, in train_and_test
    self.run_deterministic(runner, print_results=True)
  File "/home/RL/tforce_btc_trader/btc_env.py", line 471, in run_deterministic
    runner.agent.act(next_state, deterministic=False)
  File "/home/anaconda3/lib/python3.6/site-packages/tensorforce/agents/agent.py", line 145, in act
    deterministic=deterministic
  File "/home/anaconda3/lib/python3.6/site-packages/tensorforce/models/model.py", line 1268, in act

    actions, internals, timestep = self.monitored_session.run(fetches=fetches, feed_dict=feed_dict)
  File "/home/anaconda3/lib/python3.6/site-packages/tensorflow/python/training/monitored_session.py", line 536, in run
    return self._sess.run(fetches,
AttributeError: 'NoneType' object has no attribute 'run'
@TalhaAsmal
Copy link
Contributor

Hi,

Lets do some debugging:

  1. What version of python are you running?
  2. Did you import the data as stated in the readme?
  3. What version of tensorflow are you using?
  4. Approximately how long does it take for the error to occur, and what hardware are you using?

@blueboy09 blueboy09 reopened this Feb 20, 2018
@blueboy09
Copy link
Author

blueboy09 commented Feb 20, 2018

@TalhaAsmal Thanks a lot!

  1. Python 3.6.3 :: Anaconda custom (64-bit)
  2. Yes. I have done the first two steps (Setup and Populate Data). There is no error.
  3. Tensorflow: 1.5.0 (gpu), CUDA 9.0

4.1 Basic system information: Ubuntu 16.04.3 LTS, Intel(R) Xeon(R) CPU E5-2660 v3 @ 2.60GHz, GPU: TITAN Xp
4.2 It happens about 7 minutes after I start the program when it calls the function "train_and_test" (in hypersearch.py) and calls function "self.run_deterministic(runner, print_results=True)" (in btc_env) at the first time.

It seems that a possible reason is "next_start" in "runner.agent.act(next_state, deterministic=True)" is not right. It outputs as follows. But I do not know what the correct form is.

{'series': array([[[ 0.00000000e+00,  0.00000000e+00,  0.00000000e+00, ...,
          0.00000000e+00,  0.00000000e+00,  0.00000000e+00]],

       [[ 0.00000000e+00,  0.00000000e+00,  0.00000000e+00, ...,
          0.00000000e+00,  0.00000000e+00,  0.00000000e+00]],

       [[ 0.00000000e+00,  0.00000000e+00,  0.00000000e+00, ...,
          0.00000000e+00,  0.00000000e+00,  0.00000000e+00]],
       ...,

       [[ 0.00000000e+00,  0.00000000e+00,  0.00000000e+00, ...,
          0.00000000e+00,  0.00000000e+00, -3.19445158e-08]],

       [[ 0.00000000e+00,  0.00000000e+00,  0.00000000e+00, ...,
          0.00000000e+00,  0.00000000e+00, -2.96627647e-08]],

       [[ 0.00000000e+00,  0.00000000e+00,  0.00000000e+00, ...,
          0.00000000e+00,  0.00000000e+00, -2.75439958e-08]]]), 'stationary': [0.3, 0.3, 0.0]}

@blueboy09
Copy link
Author

blueboy09 commented Feb 20, 2018

@TalhaAsmal I forgot to mention one thing. I made a small modification.
Actually, if I directly run "python hypersearch.py", it has "connection is closed" error. It seems that the self.conn closed in the process because of some unknown reason. I modify line 269 in btc_env as follows.

271            conn = data.engine.connect()
272            try:
273                self.row_ct = data.count_rows(conn, arbitrage=self.hypers.arbitrage)
274            except:
275                import traceback
276                print(traceback.extract_stack())
277            finally:
278                conn.close()

@hkfreenet
Copy link

@blueboy09 I am facing the same issue as the connection is closed. i am doing the same things to make the engine connect again, then the "AttributeError: 'NoneType' object has no attribute 'run'" is coming out.

How to fix this problem?

@TalhaAsmal
Copy link
Contributor

@hkfreenet @blueboy09 Please have a look at issue #10 . I experienced the 'connection is closed' issue as well, and it was resolved with an update to tensorforce. There was no need to change the code in any way.

@blueboy09
Copy link
Author

@TalhaAsmal Thanks a lot! It works.
Actually, the current master of tensorforce also changed a lot and does not work. It would be better to specify the committed version (e.g., f1c49de3) of tensorforce in requirement.txt.

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

3 participants