0

This is the code which has some problem:

symbol_returns[i*num_samples + sample_iter] = tf.multiply(tf.cast(pos[i*num_samples + sample_iter], np.float32), y_[:,i])

daily_returns_by_symbol_ = tf.concat( [tf.reshape(t, [-1,1],1) for t in symbol_returns.values()])

But there is some error, and I have no idea how to solve it.

Traceback (most recent call last):
  File "neural_net_exec.py", line 129, in <module>
    daily_returns_by_symbol_ = tf.concat( [tf.reshape(t, [-1,1],1) for t in symbol_returns.values()])
  File "neural_net_exec.py", line 129, in <listcomp>
    daily_returns_by_symbol_ = tf.concat( [tf.reshape(t, [-1,1],1) for t in symbol_returns.values()])
  File "/anaconda/envs/tensorflow/lib/python3.5/site-packages/tensorflow/python/ops/gen_array_ops.py", line 2619, in reshape
    name=name)
  File "/anaconda/envs/tensorflow/lib/python3.5/site-packages/tensorflow/python/framework/op_def_library.py", line 374, in apply_op
    with g.as_default(), ops.name_scope(name) as scope:
  File "/anaconda/envs/tensorflow/lib/python3.5/contextlib.py", line 59, in __enter__
    return next(self.gen)
  File "/anaconda/envs/tensorflow/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 4522, in name_scope
    with g.as_default(), g.name_scope(n) as scope:
  File "/anaconda/envs/tensorflow/lib/python3.5/contextlib.py", line 59, in __enter__
    return next(self.gen)
  File "/anaconda/envs/tensorflow/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 3171, in name_scope
    if not _VALID_OP_NAME_REGEX.match(name):
TypeError: expected string or bytes-like object
2
  • You'll have to provide more details on how your data looks. For e.g. what is in symbol_returns ? Often, it is the case that this variable is empty or has data of a different type. Commented Nov 28, 2017 at 6:03
  • I've provide the symbol_returns Sorry for forgot it. Commented Nov 28, 2017 at 6:11

1 Answer 1

2

The third argument to tf.reshape, which is optional, should be a string; you have used an integer (i.e., 1) as the third argument to tf.reshape, hence the error message.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.