невозможно импортировать имя 'downsample' - PullRequest
0 голосов
/ 24 апреля 2018
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import time, math
from sklearn import linear_model, datasets
diabetes = datasets.load_diabetes()
diabetes_x = diabetes.data[:, np.newaxis] 
diabetes_x_temp = diabetes_x[:, :, 2]    
diabetes_x_train = diabetes_x_temp[:-20]
diabetes_x_test = diabetes_x_temp[-20:]
diabetes_y_train = diabetes.target[:-20]
diabetes_y_test = diabetes.target[-20:]


from sknn.mlp import Regressor, Layer
nn0=Regressor(layers=[Layer("Rectifier",units=5),Layer("Linear",units=1)],learning_rate=0.001, weight_decay=0.1,regularize='L2',learning_momentum=0.9,n_iter=20, batch_size=1, loss_type='mse',verbose=True)
x_max=max(diabetes_x_train)
nn0.fit(diabetes_x_train / x_max, diabetes_y_train)
print('Neural Network parameters:')
for param in nn0.get_parameters():
    print(param[2])
    print('\t weights: ',np.round(param[0],2))
    print('\t biases: ',np.round(param[1],2))

У меня проблема с ошибкой cannot import name downsample for line 29. Я также получаю сообщения об ошибках Theano:

DeprecationWarning: there is no c++ compiler.This is deprecated and with Theano 0.11 a c++ compiler will be mandatory
  warnings.warn("DeprecationWarning: there is no c++ compiler."
WARNING (theano.configdefaults): g++ not detected ! Theano will be unable to execute optimized C-implementations (for both CPU and GPU) and will default to Python implementations. Performance will be severely degraded. To remove this warning, set Theano flags cxx to an empty string.
WARNING (theano.tensor.blas): Using NumPy C-API based implementation for BLAS functions

Однако я не знал, что я использовал theano в этом куске кода ?! Я попытался обновить Theano до версии, которая работает с текущим пакетом Lasagne, который я использую (в настоящее время используется Theano 1.0.1 и Lasagne 0.1). Однако это, похоже, не помогло. Я очень новичок в использовании всех этих новых пакетов, поэтому любая помощь будет отличной.

...