Skip to content

运行出现AttributeError: 'int' object has no attribute 'ndim' ,不知道什么意思 #2

Description

@wang1104014663

AttributeError Traceback (most recent call last)
in ()
----> 1 train(BATCH_SIZE=36)

in train(BATCH_SIZE)
63
64 #判别器的损失;在一个batch的数据上进行一次参数更新
---> 65 d_loss = d.train_on_batch(X, y)
66 print("batch %d d_loss : %f" % (index, d_loss))
67

D:\Program Files\Anaconda3\lib\site-packages\keras\models.py in train_on_batch(self, x, y, class_weight, sample_weight)
1067 return self.model.train_on_batch(x, y,
1068 sample_weight=sample_weight,
-> 1069 class_weight=class_weight)
1070
1071 def test_on_batch(self, x, y,

D:\Program Files\Anaconda3\lib\site-packages\keras\engine\training.py in train_on_batch(self, x, y, sample_weight, class_weight)
1841 sample_weight=sample_weight,
1842 class_weight=class_weight,
-> 1843 check_batch_axis=True)
1844 if self.uses_learning_phase and not isinstance(K.learning_phase(), int):
1845 ins = x + y + sample_weights + [1.]

D:\Program Files\Anaconda3\lib\site-packages\keras\engine\training.py in _standardize_user_data(self, x, y, sample_weight, class_weight, check_batch_axis, batch_size)
1428 output_shapes,
1429 check_batch_axis=False,
-> 1430 exception_prefix='target')
1431 sample_weights = _standardize_sample_weights(sample_weight,
1432 self._feed_output_names)

D:\Program Files\Anaconda3\lib\site-packages\keras\engine\training.py in _standardize_input_data(data, names, shapes, check_batch_axis, exception_prefix)
68 elif isinstance(data, list):
69 data = [x.values if x.class.name == 'DataFrame' else x for x in data]
---> 70 data = [np.expand_dims(x, 1) if x is not None and x.ndim == 1 else x for x in data]
71 else:
72 data = data.values if data.class.name == 'DataFrame' else data

D:\Program Files\Anaconda3\lib\site-packages\keras\engine\training.py in (.0)
68 elif isinstance(data, list):
69 data = [x.values if x.class.name == 'DataFrame' else x for x in data]
---> 70 data = [np.expand_dims(x, 1) if x is not None and x.ndim == 1 else x for x in data]
71 else:
72 data = data.values if data.class.name == 'DataFrame' else data

AttributeError: 'int' object has no attribute 'ndim'

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions