0

I install Skflow and ran digits.py example on Pycharm and saw that it returns an error "AttributeError: 'module' object has no attribute 'TensorFlowDNNRegressor". I proceed and ran the same program on Ipython and everything's fine. What should be the problem?

from sklearn import datasets, cross_validation, metrics
import tensorflow as tf

import skflow
from skflow import monitors

# Load dataset

digits = datasets.load_digits()
X = digits.images
y = digits.target

# Split it into train / test subsets

X_train, X_test, y_train, y_test = cross_validation.train_test_split(X, y,
                                                                     test_size=0.2,
                                                                     random_state=42)

# Split X_train again to create validation data

X_train, X_val, y_train, y_val = cross_validation.train_test_split(X_train,
                                                                   y_train,
                                                                   test_size=0.2,
                                                                   random_state=42)

# TensorFlow model using Scikit Flow ops


def conv_model(X, y):
    X = tf.expand_dims(X, 3)
    features = tf.reduce_max(skflow.ops.conv2d(X, 12, [3, 3]), [1, 2])
    features = tf.reshape(features, [-1, 12])
    return skflow.models.logistic_regression(features, y)

val_monitor = monitors.ValidationMonitor(X_val, y_val, n_classes=10, print_steps=50)
# Create a classifier, train and predict.
classifier = skflow.TensorFlowEstimator(model_fn=conv_model, n_classes=10,
                                        steps=1000, learning_rate=0.05,
                                        batch_size=128)
classifier.fit(X_train, y_train, val_monitor)
score = metrics.accuracy_score(y_test, classifier.predict(X_test))
print('Test Accuracy: {0:f}'.format(score))

Furthermore, I learned that I have problem with any functions of Skflow on Pycharm when it works on Ipython very well. Any speculation on this?

user3147590
  • 1,231
  • 2
  • 10
  • 16

2 Answers2

0

You might check to ensure that Pycharm is using the the same python interpreter and environment as used by ipython. You can set the interpreter in pycharm in settings|Project|Project Interpreter

RobR
  • 2,160
  • 2
  • 19
  • 32
0

Is TensorFlow working well in Pycharm? If so, you can now install a nightly built TensorFlow with skflow in its contrib module.

To install a nightly built TensorFlow, see the README file on TensorFlow's Github page for instructions.

and then you can import skflow via from tensorflow.contrib.skflow.python import skflow.

Hope this helps.

Yuan Tang
  • 696
  • 4
  • 15