Skip to content

bug in DataFeeder constructor #5

@qpakzk

Description

@qpakzk

시스템 정보

  • centos 7.0
  • python 3.4
  • tensorflow 1.2.1

이의제기

x_train_dict는 딕셔너리 타입이고y_train는 배열 타입인 tensorflow.contrib.learn.DNNRegressor.fit(x_train_dict , y_train,steps=1000) 함수를 실행시켰을 때 프로그램이 다음과 같은 exception이 뜹니다.

File "/home/star/yuce.ddxq.mobi/zhuge/management/commands/forecast_product_sale.py", line 148, in tflearn_dnn_train2
    regressor.fit(x_train_dict, y_train, steps=10000, batch_size=10)
  File "/usr/lib/python3.4/site-packages/tensorflow/python/util/deprecation.py", line 289, in new_func
    return func(*args, **kwargs)
  File "/usr/lib/python3.4/site-packages/tensorflow/contrib/learn/python/learn/estimators/estimator.py", line 439, in fit
    SKCompat(self).fit(x, y, batch_size, steps, max_steps, monitors)
  File "/usr/lib/python3.4/site-packages/tensorflow/contrib/learn/python/learn/estimators/estimator.py", line 1340, in fit
    epochs=None)
  File "/usr/lib/python3.4/site-packages/tensorflow/contrib/learn/python/learn/estimators/estimator.py", line 137, in _get_input_fn
    epochs=epochs)
  File "/usr/lib/python3.4/site-packages/tensorflow/contrib/learn/python/learn/learn_io/data_feeder.py", line 152, in setup_train_data_feeder
    x, y, n_classes, batch_size, shuffle=shuffle, epochs=epochs)
  File "/usr/lib/python3.4/site-packages/tensorflow/contrib/learn/python/learn/learn_io/data_feeder.py", line 326, in __init__
    dict([(k, check_array(v, v.dtype)) for k, v in list(y.items())]) if x_is_dict else check_array(y, y.dtype)
AttributeError: 'numpy.ndarray' object has no attribute 'items'

관련된 코드는 아래와 같습니다.

 x_is_dict, y_is_dict = isinstance(x, dict), y is not None and isinstance(
        y, dict)
    if isinstance(y, list):
      y = np.array(y)

    self._x = dict([(k, check_array(v, v.dtype)) for k, v in list(x.items())
                   ]) if x_is_dict else check_array(x, x.dtype)
    self._y = None if y is None else \
      dict([(k, check_array(v, v.dtype)) for k, v in list(y.items())]) if x_is_dict else check_array(y, y.dtype)

마지막 줄이 틀린 것 같습니다. x_is_dict 말고 y_is_dict로 사용해야 하지 않나요?

dict([(k, check_array(v, v.dtype)) for k, v in list(y.items())]) if y_is_dict else check_array(y, y.dtype)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions