Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/gwt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 无法为张量';占位符_1:0';,使用core tensorflow api_Python 3.x_Tensorflow_Neural Network_Deep Learning - Fatal编程技术网

Python 3.x 无法为张量';占位符_1:0';,使用core tensorflow api

Python 3.x 无法为张量';占位符_1:0';,使用core tensorflow api,python-3.x,tensorflow,neural-network,deep-learning,Python 3.x,Tensorflow,Neural Network,Deep Learning,我正在尝试用核心张量流训练一个深度密集的神经网络。基本上,我正在根据我的数据集和我自己的编码风格调整本文中使用的代码 以下是我正在使用的数据集: 代码的主要区别在于,我从数据帧数据开始工作,而不是numpy数组,尽管如此,我相信我已经正确地调整了它。我得到的错误是 Cannot feed value of shape (242,) for Tensor 'Placeholder_1:0', which has shape '(242, 1)' 这里是我的全部代码:数据加载和库导入 impor

我正在尝试用核心张量流训练一个深度密集的神经网络。基本上,我正在根据我的数据集和我自己的编码风格调整本文中使用的代码

以下是我正在使用的数据集:

代码的主要区别在于,我从数据帧数据开始工作,而不是numpy数组,尽管如此,我相信我已经正确地调整了它。我得到的错误是

Cannot feed value of shape (242,) for Tensor 'Placeholder_1:0', which has shape '(242, 1)'
这里是我的全部代码:数据加载和库导入

import pandas as pd



from sklearn.utils import shuffle
from sklearn.model_selection import train_test_split
import numpy as np
import tensorflow as tf
import tensorflow.compat.v1 as tf

tf.disable_v2_behavior()



 df= pd.read_csv('/home/nacho/Descargas/datasets/heart-disease-uci/heart.csv')
可变分配:

X = df.drop('target', axis = 1)

Y = df["target"]

X,Y = shuffle (X, Y, random_state = 0)

train_x, test_x, train_y, test_y = train_test_split(X, Y, test_size = 0.20, random_state = 0)
网络的理论架构:

# The learning rate we want for our gradient descent, and the number of epochs
# We want to use to train our data

learning_rate = 0.2
training_epochs = 500 

# The number of layers we want, with the number of neurons we want them 
n_hidden_1 = 60
n_hidden_2 = 60
n_hidden_3 = 60
n_hidden_4 = 60

# Define cost function and training algorithm 

costf = 'cross entropy'
traininga = "gradient descent optimizer"
创建将放置在神经网络中的对象

# We define the inputs as placeholder, we shall fill them when we execute our code
n_dim = X.shape[1] # This will help define the vectors and matrices for calculation correctly
n_class = 1 # The number  of categorie values possibles for Y 

 # We need to solve the  nlen thing 


x = tf.placeholder( tf.float32, [None, n_dim])   # Specifying where we are going to put the vectors 
y_ = tf.placeholder(tf.float32, [None, n_class])


# We define out weights and bias as variables also
W = tf.Variable(tf.zeros([n_dim, n_class]))
b = tf.Variable(tf.zeros([n_class]))


weights = {
    'h1': tf.Variable(tf.truncated_normal([n_dim, n_hidden_1])),
    'h2': tf.Variable(tf.truncated_normal([n_hidden_1, n_hidden_2])),
    'h3': tf.Variable(tf.truncated_normal([n_hidden_2, n_hidden_3])),
    'h4': tf.Variable(tf.truncated_normal([n_hidden_3, n_hidden_4])),
    'out': tf.Variable(tf.truncated_normal([n_hidden_4, n_class]))
}


biases = {
    'b1': tf.Variable(tf.truncated_normal([n_hidden_1])),
    'b2': tf.Variable(tf.truncated_normal([n_hidden_2])),
    'b3': tf.Variable(tf.truncated_normal([n_hidden_3])),
    'b4': tf.Variable(tf.truncated_normal([n_hidden_4])),
    'out': tf.Variable(tf.truncated_normal([n_class]))
}
对模型进行编码:

def multilayer_perceptron(x, weights, biases):

    # Hidden layer with RELU activationsd
    layer_1 = tf.add(tf.matmul(x, weights['h1']), biases['b1'])
    layer_1 = tf.nn.relu(layer_1)

    # Hidden layer with sigmoid activation
    layer_2 = tf.add(tf.matmul(layer_1, weights['h2']), biases['b2'])
    layer_2 = tf.nn.relu(layer_2)

    # Hidden layer with sigmoid activation
    layer_3 = tf.add(tf.matmul(layer_2, weights['h3']), biases['b3'])
    layer_3 = tf.nn.relu(layer_3)

    # Hidden layer with RELU activation
    layer_4 = tf.add(tf.matmul(layer_3, weights['h4']), biases['b4'])
    layer_4 = tf.nn.sigmoid(layer_4)

    # Output layer with linear activation
    out_layer = tf.matmul(layer_4, weights['out']) + biases['out']
    return out_layer


# Calling model
y = multilayer_perceptron(x, weights, biases) # Basically, this will execute all our layers computations, resulting
# in a tensor y with our predicted results. 


cost_function = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(logits=y, labels=y_)) #  Calculates the cross_entropy 
training_step = tf.train.GradientDescentOptimizer(learning_rate).minimize(cost_function)
编码额外的对象,这将允许我们以后获得额外的数据

# We are going to create lists, that will allow us to plot the evolution of the epochs accuracy and error after traini
mse_history = []
accuracy_history = []
对执行进行编码(注意,这里是错误发生的地方)

我们得到的错误是:

ValueError                                Traceback (most recent call last)
<ipython-input-33-91216a39c8b4> in <module>
      1 for epoch in range(training_epochs):
----> 2     sess.run(training_step, feed_dict = {x: train_x, y_: train_y})  # We start with the training
      3     cost = sess.run(cost_function, feed_dict={x: train_x, y_: train_y}) #We calculate the loss for that epoch
      4     cost_history = np.append(cost_history, cost) # With that loss calculted we append it to a list
      5     correct_prediction = tf.equal(tf.argmax(y, 1), tf.argmax(y_, 1))  # We calculate what would be the correct prediction

~/anaconda3/envs/deepl1/lib/python3.6/site-packages/tensorflow/python/client/session.py in run(self, fetches, feed_dict, options, run_metadata)
    928     try:
    929       result = self._run(None, fetches, feed_dict, options_ptr,
--> 930                          run_metadata_ptr)
    931       if run_metadata:
    932         proto_data = tf_session.TF_GetBuffer(run_metadata_ptr)

~/anaconda3/envs/deepl1/lib/python3.6/site-packages/tensorflow/python/client/session.py in _run(self, handle, fetches, feed_dict, options, run_metadata)
   1127                              'which has shape %r' %
   1128                              (np_val.shape, subfeed_t.name,
-> 1129                               str(subfeed_t.get_shape())))
   1130           if not self.graph.is_feedable(subfeed_t):
   1131             raise ValueError('Tensor %s may not be fed.' % subfeed_t)

ValueError: Cannot feed value of shape (242,) for Tensor 'Placeholder_1:0', which has shape '(242, 1)'
我会一直工作,我只想了解tensorflow

****编辑日期:2019年5月2日:****

所以我改变了以下几行,我得到了一些有趣的进展:

x = tf.placeholder(tf.float32)   # Specifying where we are going to put the vectors 
y_ = tf.placeholder(tf.float32)
刚开始更改这两行,将显示的错误更改为:

---------------------------------------------------------------------------
Exception                                 Traceback (most recent call last)
<ipython-input-142-91216a39c8b4> in <module>
      6     accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32)) # We define a function to calculate accuracy
      7     pred_y = sess.run(y, feed_dict = {x: test_x}) # Predict after training in the epoch
----> 8     mse = tf.reduce_mean(tf.square(pred_y - test_y)) # define a function to Calculate the error of that epoch
      9     mse_ = sess.run(mse)  # we run said function
     10     mse_history.append(mse_)  # We append the result to a list

~/anaconda3/envs/deepl1/lib/python3.6/site-packages/pandas/core/ops.py in wrapper(left, right)
   1583         result = safe_na_op(lvalues, rvalues)
   1584         return construct_result(left, result,
-> 1585                                 index=left.index, name=res_name, dtype=None)
   1586 
   1587     wrapper.__name__ = op_name

~/anaconda3/envs/deepl1/lib/python3.6/site-packages/pandas/core/ops.py in _construct_result(left, result, index, name, dtype)
   1472     not be enough; we still need to override the name attribute.
   1473     """
-> 1474     out = left._constructor(result, index=index, dtype=dtype)
   1475 
   1476     out.name = name

~/anaconda3/envs/deepl1/lib/python3.6/site-packages/pandas/core/series.py in __init__(self, data, index, dtype, name, copy, fastpath)
    260             else:
    261                 data = sanitize_array(data, index, dtype, copy,
--> 262                                       raise_cast_failure=True)
    263 
    264                 data = SingleBlockManager(data, index, fastpath=True)

~/anaconda3/envs/deepl1/lib/python3.6/site-packages/pandas/core/internals/construction.py in sanitize_array(data, index, dtype, copy, raise_cast_failure)
    656     elif subarr.ndim > 1:
    657         if isinstance(data, np.ndarray):
--> 658             raise Exception('Data must be 1-dimensional')
    659         else:
    660             subarr = com.asarray_tuplesafe(data, dtype=dtype)

Exception: Data must be 1-dimensional
这一点改变了,再次出现了错误 对下列事项:

---------------------------------------------------------------------------
InvalidArgumentError                      Traceback (most recent call last)
~/anaconda3/envs/deepl1/lib/python3.6/site-packages/tensorflow/python/client/session.py in _do_call(self, fn, *args)
   1334     try:
-> 1335       return fn(*args)
   1336     except errors.OpError as e:

~/anaconda3/envs/deepl1/lib/python3.6/site-packages/tensorflow/python/client/session.py in _run_fn(feed_dict, fetch_list, target_list, options, run_metadata)
   1319       return self._call_tf_sessionrun(
-> 1320           options, feed_dict, fetch_list, target_list, run_metadata)
   1321 

~/anaconda3/envs/deepl1/lib/python3.6/site-packages/tensorflow/python/client/session.py in _call_tf_sessionrun(self, options, feed_dict, fetch_list, target_list, run_metadata)
   1407         self._session, options, feed_dict, fetch_list, target_list,
-> 1408         run_metadata)
   1409 

InvalidArgumentError: Expected dimension in the range [-1, 1), but got 1
     [[{{node ArgMax_1561}}]]

During handling of the above exception, another exception occurred:

InvalidArgumentError                      Traceback (most recent call last)
<ipython-input-176-fc9234678b87> in <module>
      9     mse_ = sess.run(mse)  # we run said function
     10     mse_history.append(mse_)  # We append the result to a list
---> 11     accuracy = (sess.run(accuracy, feed_dict={x: train_x.values, y_: train_y.values})) # Execute the accuracy function
     12     accuracy_history.append(accuracy)

~/anaconda3/envs/deepl1/lib/python3.6/site-packages/tensorflow/python/client/session.py in run(self, fetches, feed_dict, options, run_metadata)
    928     try:
    929       result = self._run(None, fetches, feed_dict, options_ptr,
--> 930                          run_metadata_ptr)
    931       if run_metadata:
    932         proto_data = tf_session.TF_GetBuffer(run_metadata_ptr)

~/anaconda3/envs/deepl1/lib/python3.6/site-packages/tensorflow/python/client/session.py in _run(self, handle, fetches, feed_dict, options, run_metadata)
   1151     if final_fetches or final_targets or (handle and feed_dict_tensor):
   1152       results = self._do_run(handle, final_targets, final_fetches,
-> 1153                              feed_dict_tensor, options, run_metadata)
   1154     else:
   1155       results = []

~/anaconda3/envs/deepl1/lib/python3.6/site-packages/tensorflow/python/client/session.py in _do_run(self, handle, target_list, fetch_list, feed_dict, options, run_metadata)
   1327     if handle is None:
   1328       return self._do_call(_run_fn, feeds, fetches, targets, options,
-> 1329                            run_metadata)
   1330     else:
   1331       return self._do_call(_prun_fn, handle, feeds, fetches)

~/anaconda3/envs/deepl1/lib/python3.6/site-packages/tensorflow/python/client/session.py in _do_call(self, fn, *args)
   1347           pass
   1348       message = error_interpolation.interpolate(message, self._graph)
-> 1349       raise type(e)(node_def, op, message)
   1350 
   1351   def _extend_graph(self):

InvalidArgumentError: Expected dimension in the range [-1, 1), but got 1
     [[node ArgMax_1561 (defined at <ipython-input-176-fc9234678b87>:5) ]]

Errors may have originated from an input operation.
Input Source operations connected to node ArgMax_1561:
 Placeholder_19 (defined at <ipython-input-166-844432d3b8cf>:11)

Original stack trace for 'ArgMax_1561':
  File "/home/nacho/anaconda3/envs/deepl1/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/home/nacho/anaconda3/envs/deepl1/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/nacho/anaconda3/envs/deepl1/lib/python3.6/site-packages/ipykernel_launcher.py", line 16, in <module>
    app.launch_new_instance()
  File "/home/nacho/anaconda3/envs/deepl1/lib/python3.6/site-packages/traitlets/config/application.py", line 658, in launch_instance
    app.start()
  File "/home/nacho/anaconda3/envs/deepl1/lib/python3.6/site-packages/ipykernel/kernelapp.py", line 505, in start
    self.io_loop.start()
  File "/home/nacho/anaconda3/envs/deepl1/lib/python3.6/site-packages/tornado/platform/asyncio.py", line 148, in start
    self.asyncio_loop.run_forever()
  File "/home/nacho/anaconda3/envs/deepl1/lib/python3.6/asyncio/base_events.py", line 438, in run_forever
    self._run_once()
  File "/home/nacho/anaconda3/envs/deepl1/lib/python3.6/asyncio/base_events.py", line 1451, in _run_once
    handle._run()
  File "/home/nacho/anaconda3/envs/deepl1/lib/python3.6/asyncio/events.py", line 145, in _run
    self._callback(*self._args)
  File "/home/nacho/anaconda3/envs/deepl1/lib/python3.6/site-packages/tornado/ioloop.py", line 690, in <lambda>
    lambda f: self._run_callback(functools.partial(callback, future))
  File "/home/nacho/anaconda3/envs/deepl1/lib/python3.6/site-packages/tornado/ioloop.py", line 743, in _run_callback
    ret = callback()
  File "/home/nacho/anaconda3/envs/deepl1/lib/python3.6/site-packages/tornado/gen.py", line 781, in inner
    self.run()
  File "/home/nacho/anaconda3/envs/deepl1/lib/python3.6/site-packages/tornado/gen.py", line 742, in run
    yielded = self.gen.send(value)
  File "/home/nacho/anaconda3/envs/deepl1/lib/python3.6/site-packages/ipykernel/kernelbase.py", line 357, in process_one
    yield gen.maybe_future(dispatch(*args))
  File "/home/nacho/anaconda3/envs/deepl1/lib/python3.6/site-packages/tornado/gen.py", line 209, in wrapper
    yielded = next(result)
  File "/home/nacho/anaconda3/envs/deepl1/lib/python3.6/site-packages/ipykernel/kernelbase.py", line 267, in dispatch_shell
    yield gen.maybe_future(handler(stream, idents, msg))
  File "/home/nacho/anaconda3/envs/deepl1/lib/python3.6/site-packages/tornado/gen.py", line 209, in wrapper
    yielded = next(result)
  File "/home/nacho/anaconda3/envs/deepl1/lib/python3.6/site-packages/ipykernel/kernelbase.py", line 534, in execute_request
    user_expressions, allow_stdin,
  File "/home/nacho/anaconda3/envs/deepl1/lib/python3.6/site-packages/tornado/gen.py", line 209, in wrapper
    yielded = next(result)
  File "/home/nacho/anaconda3/envs/deepl1/lib/python3.6/site-packages/ipykernel/ipkernel.py", line 294, in do_execute
    res = shell.run_cell(code, store_history=store_history, silent=silent)
  File "/home/nacho/anaconda3/envs/deepl1/lib/python3.6/site-packages/ipykernel/zmqshell.py", line 536, in run_cell
    return super(ZMQInteractiveShell, self).run_cell(*args, **kwargs)
  File "/home/nacho/anaconda3/envs/deepl1/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 2848, in run_cell
    raw_cell, store_history, silent, shell_futures)
  File "/home/nacho/anaconda3/envs/deepl1/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 2874, in _run_cell
    return runner(coro)
  File "/home/nacho/anaconda3/envs/deepl1/lib/python3.6/site-packages/IPython/core/async_helpers.py", line 67, in _pseudo_sync_runner
    coro.send(None)
  File "/home/nacho/anaconda3/envs/deepl1/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 3049, in run_cell_async
    interactivity=interactivity, compiler=compiler, result=result)
  File "/home/nacho/anaconda3/envs/deepl1/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 3214, in run_ast_nodes
    if (yield from self.run_code(code, result)):
  File "/home/nacho/anaconda3/envs/deepl1/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 3296, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-176-fc9234678b87>", line 5, in <module>
    correct_prediction = tf.equal(tf.argmax(y, 1), tf.argmax(y_, 1))  # We calculate what would be the correct prediction
  File "/home/nacho/anaconda3/envs/deepl1/lib/python3.6/site-packages/tensorflow/python/util/deprecation.py", line 507, in new_func
    return func(*args, **kwargs)
  File "/home/nacho/anaconda3/envs/deepl1/lib/python3.6/site-packages/tensorflow/python/ops/math_ops.py", line 137, in argmax
    return argmax_v2(input, axis, output_type, name)
  File "/home/nacho/anaconda3/envs/deepl1/lib/python3.6/site-packages/tensorflow/python/ops/math_ops.py", line 166, in argmax_v2
    return gen_math_ops.arg_max(input, axis, name=name, output_type=output_type)
  File "/home/nacho/anaconda3/envs/deepl1/lib/python3.6/site-packages/tensorflow/python/ops/gen_math_ops.py", line 938, in arg_max
    name=name)
  File "/home/nacho/anaconda3/envs/deepl1/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 800, in _apply_op_helper
    op_def=op_def)
  File "/home/nacho/anaconda3/envs/deepl1/lib/python3.6/site-packages/tensorflow/python/util/deprecation.py", line 507, in new_func
    return func(*args, **kwargs)
  File "/home/nacho/anaconda3/envs/deepl1/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 3479, in create_op
    op_def=op_def)
  File "/home/nacho/anaconda3/envs/deepl1/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1961, in __init__
    self._traceback = tf_stack.extract_stack()

代码似乎起作用了。所以问题一定就在附近

可以尝试以下方法之一:

  • 对于占位符,形状参数是可选的。从文档中可以看出,要馈送的张量的形状(可选)。如果未指定形状,则可以输入任何形状的张量

    x=tf.placeholder(tf.float32)
    
  • 使用np展开x列或y列的尺寸。展开尺寸

    train_x=np.展开_dims(train_x,-1)#添加新轴
    

  • 所以,当我使用第一个解决方案时,错误变为异常:数据必须是一维的,哪一行会出现错误?请发布更新的错误堆栈跟踪。我添加了所有代码错误更改,我觉得问题变得太长了(它也发生了变化,因为我使用您的解决方案1+将train_x更改为train_x.values(还更改了train_x、test_x和text_y添加了它们。values)+删除最后两行精度。在这种情况下,堆栈协议是什么?我应该删除问题还是删除新错误,并将其发布到新错误上?我担心新错误可能与旧错误有关。这是发生在代码中不同位置的不同错误。因此,理想情况下应该是不同的问题。我hink y是一维的,在执行tf.argmax时会导致问题。
    ---------------------------------------------------------------------------
    Exception                                 Traceback (most recent call last)
    <ipython-input-142-91216a39c8b4> in <module>
          6     accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32)) # We define a function to calculate accuracy
          7     pred_y = sess.run(y, feed_dict = {x: test_x}) # Predict after training in the epoch
    ----> 8     mse = tf.reduce_mean(tf.square(pred_y - test_y)) # define a function to Calculate the error of that epoch
          9     mse_ = sess.run(mse)  # we run said function
         10     mse_history.append(mse_)  # We append the result to a list
    
    ~/anaconda3/envs/deepl1/lib/python3.6/site-packages/pandas/core/ops.py in wrapper(left, right)
       1583         result = safe_na_op(lvalues, rvalues)
       1584         return construct_result(left, result,
    -> 1585                                 index=left.index, name=res_name, dtype=None)
       1586 
       1587     wrapper.__name__ = op_name
    
    ~/anaconda3/envs/deepl1/lib/python3.6/site-packages/pandas/core/ops.py in _construct_result(left, result, index, name, dtype)
       1472     not be enough; we still need to override the name attribute.
       1473     """
    -> 1474     out = left._constructor(result, index=index, dtype=dtype)
       1475 
       1476     out.name = name
    
    ~/anaconda3/envs/deepl1/lib/python3.6/site-packages/pandas/core/series.py in __init__(self, data, index, dtype, name, copy, fastpath)
        260             else:
        261                 data = sanitize_array(data, index, dtype, copy,
    --> 262                                       raise_cast_failure=True)
        263 
        264                 data = SingleBlockManager(data, index, fastpath=True)
    
    ~/anaconda3/envs/deepl1/lib/python3.6/site-packages/pandas/core/internals/construction.py in sanitize_array(data, index, dtype, copy, raise_cast_failure)
        656     elif subarr.ndim > 1:
        657         if isinstance(data, np.ndarray):
    --> 658             raise Exception('Data must be 1-dimensional')
        659         else:
        660             subarr = com.asarray_tuplesafe(data, dtype=dtype)
    
    Exception: Data must be 1-dimensional
    
    for epoch in range(training_epochs):
        sess.run(training_step, feed_dict = {x: train_x.values, y_: train_y.values})  # We start with the training
        cost = sess.run(cost_function, feed_dict={x: train_x.values, y_: train_y.values}) #We calculate the loss for that epoch
        cost_history = np.append(cost_history, cost) # With that loss calculted we append it to a list
        correct_prediction = tf.equal(tf.argmax(y, 1), tf.argmax(y_, 1))  # We calculate what would be the correct prediction
        accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32)) # We define a function to calculate accuracy 
        pred_y = sess.run(y, feed_dict = {x: test_x.values}) # Predict after training in the epoch
        mse = tf.reduce_mean(tf.square(pred_y - test_y.values)) # define a function to Calculate the error of that epoch
        mse_ = sess.run(mse)  # we run said function
        mse_history.append(mse_)  # We append the result to a list
        accuracy = (sess.run(accuracy, feed_dict={x: train_x.values, y_: train_y.values})) # Execute the accuracy function
        accuracy_history.append(accuracy) 
    
    ---------------------------------------------------------------------------
    InvalidArgumentError                      Traceback (most recent call last)
    ~/anaconda3/envs/deepl1/lib/python3.6/site-packages/tensorflow/python/client/session.py in _do_call(self, fn, *args)
       1334     try:
    -> 1335       return fn(*args)
       1336     except errors.OpError as e:
    
    ~/anaconda3/envs/deepl1/lib/python3.6/site-packages/tensorflow/python/client/session.py in _run_fn(feed_dict, fetch_list, target_list, options, run_metadata)
       1319       return self._call_tf_sessionrun(
    -> 1320           options, feed_dict, fetch_list, target_list, run_metadata)
       1321 
    
    ~/anaconda3/envs/deepl1/lib/python3.6/site-packages/tensorflow/python/client/session.py in _call_tf_sessionrun(self, options, feed_dict, fetch_list, target_list, run_metadata)
       1407         self._session, options, feed_dict, fetch_list, target_list,
    -> 1408         run_metadata)
       1409 
    
    InvalidArgumentError: Expected dimension in the range [-1, 1), but got 1
         [[{{node ArgMax_1561}}]]
    
    During handling of the above exception, another exception occurred:
    
    InvalidArgumentError                      Traceback (most recent call last)
    <ipython-input-176-fc9234678b87> in <module>
          9     mse_ = sess.run(mse)  # we run said function
         10     mse_history.append(mse_)  # We append the result to a list
    ---> 11     accuracy = (sess.run(accuracy, feed_dict={x: train_x.values, y_: train_y.values})) # Execute the accuracy function
         12     accuracy_history.append(accuracy)
    
    ~/anaconda3/envs/deepl1/lib/python3.6/site-packages/tensorflow/python/client/session.py in run(self, fetches, feed_dict, options, run_metadata)
        928     try:
        929       result = self._run(None, fetches, feed_dict, options_ptr,
    --> 930                          run_metadata_ptr)
        931       if run_metadata:
        932         proto_data = tf_session.TF_GetBuffer(run_metadata_ptr)
    
    ~/anaconda3/envs/deepl1/lib/python3.6/site-packages/tensorflow/python/client/session.py in _run(self, handle, fetches, feed_dict, options, run_metadata)
       1151     if final_fetches or final_targets or (handle and feed_dict_tensor):
       1152       results = self._do_run(handle, final_targets, final_fetches,
    -> 1153                              feed_dict_tensor, options, run_metadata)
       1154     else:
       1155       results = []
    
    ~/anaconda3/envs/deepl1/lib/python3.6/site-packages/tensorflow/python/client/session.py in _do_run(self, handle, target_list, fetch_list, feed_dict, options, run_metadata)
       1327     if handle is None:
       1328       return self._do_call(_run_fn, feeds, fetches, targets, options,
    -> 1329                            run_metadata)
       1330     else:
       1331       return self._do_call(_prun_fn, handle, feeds, fetches)
    
    ~/anaconda3/envs/deepl1/lib/python3.6/site-packages/tensorflow/python/client/session.py in _do_call(self, fn, *args)
       1347           pass
       1348       message = error_interpolation.interpolate(message, self._graph)
    -> 1349       raise type(e)(node_def, op, message)
       1350 
       1351   def _extend_graph(self):
    
    InvalidArgumentError: Expected dimension in the range [-1, 1), but got 1
         [[node ArgMax_1561 (defined at <ipython-input-176-fc9234678b87>:5) ]]
    
    Errors may have originated from an input operation.
    Input Source operations connected to node ArgMax_1561:
     Placeholder_19 (defined at <ipython-input-166-844432d3b8cf>:11)
    
    Original stack trace for 'ArgMax_1561':
      File "/home/nacho/anaconda3/envs/deepl1/lib/python3.6/runpy.py", line 193, in _run_module_as_main
        "__main__", mod_spec)
      File "/home/nacho/anaconda3/envs/deepl1/lib/python3.6/runpy.py", line 85, in _run_code
        exec(code, run_globals)
      File "/home/nacho/anaconda3/envs/deepl1/lib/python3.6/site-packages/ipykernel_launcher.py", line 16, in <module>
        app.launch_new_instance()
      File "/home/nacho/anaconda3/envs/deepl1/lib/python3.6/site-packages/traitlets/config/application.py", line 658, in launch_instance
        app.start()
      File "/home/nacho/anaconda3/envs/deepl1/lib/python3.6/site-packages/ipykernel/kernelapp.py", line 505, in start
        self.io_loop.start()
      File "/home/nacho/anaconda3/envs/deepl1/lib/python3.6/site-packages/tornado/platform/asyncio.py", line 148, in start
        self.asyncio_loop.run_forever()
      File "/home/nacho/anaconda3/envs/deepl1/lib/python3.6/asyncio/base_events.py", line 438, in run_forever
        self._run_once()
      File "/home/nacho/anaconda3/envs/deepl1/lib/python3.6/asyncio/base_events.py", line 1451, in _run_once
        handle._run()
      File "/home/nacho/anaconda3/envs/deepl1/lib/python3.6/asyncio/events.py", line 145, in _run
        self._callback(*self._args)
      File "/home/nacho/anaconda3/envs/deepl1/lib/python3.6/site-packages/tornado/ioloop.py", line 690, in <lambda>
        lambda f: self._run_callback(functools.partial(callback, future))
      File "/home/nacho/anaconda3/envs/deepl1/lib/python3.6/site-packages/tornado/ioloop.py", line 743, in _run_callback
        ret = callback()
      File "/home/nacho/anaconda3/envs/deepl1/lib/python3.6/site-packages/tornado/gen.py", line 781, in inner
        self.run()
      File "/home/nacho/anaconda3/envs/deepl1/lib/python3.6/site-packages/tornado/gen.py", line 742, in run
        yielded = self.gen.send(value)
      File "/home/nacho/anaconda3/envs/deepl1/lib/python3.6/site-packages/ipykernel/kernelbase.py", line 357, in process_one
        yield gen.maybe_future(dispatch(*args))
      File "/home/nacho/anaconda3/envs/deepl1/lib/python3.6/site-packages/tornado/gen.py", line 209, in wrapper
        yielded = next(result)
      File "/home/nacho/anaconda3/envs/deepl1/lib/python3.6/site-packages/ipykernel/kernelbase.py", line 267, in dispatch_shell
        yield gen.maybe_future(handler(stream, idents, msg))
      File "/home/nacho/anaconda3/envs/deepl1/lib/python3.6/site-packages/tornado/gen.py", line 209, in wrapper
        yielded = next(result)
      File "/home/nacho/anaconda3/envs/deepl1/lib/python3.6/site-packages/ipykernel/kernelbase.py", line 534, in execute_request
        user_expressions, allow_stdin,
      File "/home/nacho/anaconda3/envs/deepl1/lib/python3.6/site-packages/tornado/gen.py", line 209, in wrapper
        yielded = next(result)
      File "/home/nacho/anaconda3/envs/deepl1/lib/python3.6/site-packages/ipykernel/ipkernel.py", line 294, in do_execute
        res = shell.run_cell(code, store_history=store_history, silent=silent)
      File "/home/nacho/anaconda3/envs/deepl1/lib/python3.6/site-packages/ipykernel/zmqshell.py", line 536, in run_cell
        return super(ZMQInteractiveShell, self).run_cell(*args, **kwargs)
      File "/home/nacho/anaconda3/envs/deepl1/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 2848, in run_cell
        raw_cell, store_history, silent, shell_futures)
      File "/home/nacho/anaconda3/envs/deepl1/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 2874, in _run_cell
        return runner(coro)
      File "/home/nacho/anaconda3/envs/deepl1/lib/python3.6/site-packages/IPython/core/async_helpers.py", line 67, in _pseudo_sync_runner
        coro.send(None)
      File "/home/nacho/anaconda3/envs/deepl1/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 3049, in run_cell_async
        interactivity=interactivity, compiler=compiler, result=result)
      File "/home/nacho/anaconda3/envs/deepl1/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 3214, in run_ast_nodes
        if (yield from self.run_code(code, result)):
      File "/home/nacho/anaconda3/envs/deepl1/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 3296, in run_code
        exec(code_obj, self.user_global_ns, self.user_ns)
      File "<ipython-input-176-fc9234678b87>", line 5, in <module>
        correct_prediction = tf.equal(tf.argmax(y, 1), tf.argmax(y_, 1))  # We calculate what would be the correct prediction
      File "/home/nacho/anaconda3/envs/deepl1/lib/python3.6/site-packages/tensorflow/python/util/deprecation.py", line 507, in new_func
        return func(*args, **kwargs)
      File "/home/nacho/anaconda3/envs/deepl1/lib/python3.6/site-packages/tensorflow/python/ops/math_ops.py", line 137, in argmax
        return argmax_v2(input, axis, output_type, name)
      File "/home/nacho/anaconda3/envs/deepl1/lib/python3.6/site-packages/tensorflow/python/ops/math_ops.py", line 166, in argmax_v2
        return gen_math_ops.arg_max(input, axis, name=name, output_type=output_type)
      File "/home/nacho/anaconda3/envs/deepl1/lib/python3.6/site-packages/tensorflow/python/ops/gen_math_ops.py", line 938, in arg_max
        name=name)
      File "/home/nacho/anaconda3/envs/deepl1/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 800, in _apply_op_helper
        op_def=op_def)
      File "/home/nacho/anaconda3/envs/deepl1/lib/python3.6/site-packages/tensorflow/python/util/deprecation.py", line 507, in new_func
        return func(*args, **kwargs)
      File "/home/nacho/anaconda3/envs/deepl1/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 3479, in create_op
        op_def=op_def)
      File "/home/nacho/anaconda3/envs/deepl1/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1961, in __init__
        self._traceback = tf_stack.extract_stack()
    
    accuracy = (sess.run(accuracy, feed_dict={x: train_x.values, y_: train_y.values})) # Execute the accuracy function
        accuracy_history.append(accuracy)