Skip to content

bug in DataFeeder constructor #9

@zxcv551133

Description

@zxcv551133

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)

이고,

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