Я получаю следующую ошибку при запуске приведенного ниже кода.Он останавливается на обучении.
ПРЕДУПРЕЖДЕНИЕ (theano.configdefaults): g ++ недоступен, если используется conda: conda install m2w64-toolchain
D: \ ANACONDA \ lib \ site-packages \ theano \ configdefaults.py: 560:
UserWarning: DeprecationWarning: нет компилятора c ++. Это устарело, и с Theano 0.11 компилятор c ++ будет обязательным warnings.warn («DeprecationWarning: компилятора c ++ нет.»
ПРЕДУПРЕЖДЕНИЕ (theano.configdefaults): g ++ не обнаружен! Theano не сможет выполнить оптимизированные реализации C (как для CPU, так и для GPU) и по умолчанию будет использовать реализации Python. Производительность будет сильно снижена. Чтобы удалить это предупреждение, установите флажки Theano cxxв пустую строку.
ПРЕДУПРЕЖДЕНИЕ (theano.tensor.blas): Использование реализации на основе NumPy C-API для функций BLAS.
batch_size = 100
alpha = 0.1
epsilon = 0.0001
num_units = 8
n_hidden_layers = 3
num_epochs = 1000
dropout_in = 0.2
dropout_hidden = 0.5
activation = binary_net.binary_tanh_unit
binary = True
stochastic = False
H = 1.0
W_LR_scale = Glorot
LR_start = 0.003
LR_fin = 3e-07
LR_decay = 0.9908319448927676
save_path = mnist_parameters.npz
shuffle_parts = 1
Loading MNIST dataset...
Building the MLP...
W_LR_scale = 22.97825
H = 1.0
W_LR_scale = 3.2659864
H = 1.0
W_LR_scale = 3.2659864
H = 1.0
W_LR_scale = 3.4641016
H = 1.0
Training...
MethodNotDefined: ('impl', 'Round3') Применить узел, вызвавший ошибку: Elemwise {Composite {(i0 * (i1 + (i0 * round3 (clip (i2, i3, i4))))) * i5)}} [(0, 2)] (TensorConstant {(1, 1) из 2,0}, TensorConstant {(1, 1) из -1.0}, Elemwise {Composite {(i0 * (i1 + (i2 * i3 * i4) + i5))}}. 0, TensorConstant {(1, 1) из 0}, TensorConstant{(1, 1) из 1}, Elemwise {Composite {Cast {float32} (LT (i0, i1))}} [(0, 0)]. 0) Индекс топосорта: 82 Типы входных данных: [TensorType (float32,(True, True)), TensorType (float32, (True, True)), TensorType (float32, matrix), TensorType (int8, (True, True)), TensorType (int8, (True, True)), TensorType (float32, матрица)] Входные формы: [(1, 1), (1, 1), (100, 8), (1, 1), (1, 1), (100, 8)] Входные шаги: [(4, 4), (4, 4), (32, 4), (1, 1), (1, 1), (32, 4)] Входные значения: [массив ([[2.]], Dtype = float32), массив ([[- 1.]], dtype = float32), «не показан», массив ([[0]], dtype = int8), массив ([[1]], dtype = int8), «непоказано '] Выходные клиенты: [[InplaceDimShuffle {1,0} (Elemwise {Composite {(i0 * (i1 + (i0 * round3) (клип (i2, i3, i4)))) * i5)}} [(0,2)]. 0), Dot22 (Elemwise {Composite {(i0 * (i1 + (i0 * round3 (clip (i2, i3, i4))))) * i5)}} [(0, 2)]. 0,Elemwise {Composite {Switch (RoundHalfToEven (clip ((i0 * (i1 + i2)), i3, i4)), i1, i5)}}. 0)]]
СОВЕТ: повторный запуск с большинством отключенных оптимизаций Theano может дать вам обратную трассировку, когда этот узел был создан.Это можно сделать, установив флаг Theano 'optimizer = fast_compile'.Если это не работает, оптимизацию Theano можно отключить с помощью «optimizer = None».СОВЕТ: Используйте флаг Theano 'exception_verbosity = high' для отпечатка отладочной карты и карты хранения этого применяемого узла.
Здесь ниже мой код:
from __future__ import print_function
import sys
import os
import time
import numpy as np
np.random.seed(1234) # for reproducibility
import theano.tensor as T
import lasagne
from lasagne.layers import get_all_layers
import pickle
import gzip
import binary_net
from pylearn2.datasets.mnist import MNIST
from pylearn2.utils import serial
from collections import OrderedDict
if __name__ == "__main__":
# BN parameters
batch_size = 100
print("batch_size = "+str(batch_size))
# alpha is the exponential moving average factor
# alpha = .15
alpha = .1
print("alpha = "+str(alpha))
epsilon = 1e-4
print("epsilon = "+str(epsilon))
# MLP parameters
num_units = 8
print("num_units = "+str(num_units))
n_hidden_layers = 3
print("n_hidden_layers = "+str(n_hidden_layers))
# Training parameters
num_epochs = 1000
print("num_epochs = "+str(num_epochs))
# Dropout parameters
dropout_in = .2 # 0. means no dropout
print("dropout_in = "+str(dropout_in))
dropout_hidden = .5
print("dropout_hidden = "+str(dropout_hidden))
# BinaryOut
activation = binary_net.binary_tanh_unit
print("activation = binary_net.binary_tanh_unit")
# activation = binary_net.binary_sigmoid_unit
# print("activation = binary_net.binary_sigmoid_unit")
# BinaryConnect
binary = True
print("binary = "+str(binary))
stochastic = False
print("stochastic = "+str(stochastic))
# (-H,+H) are the two binary values
# H = "Glorot"
H = 1.
print("H = "+str(H))
# W_LR_scale = 1.
W_LR_scale = "Glorot" # "Glorot" means we are using the coefficients from Glorot's paper
print("W_LR_scale = "+str(W_LR_scale))
# Decaying LR
LR_start = .003
print("LR_start = "+str(LR_start))
LR_fin = 0.0000003
print("LR_fin = "+str(LR_fin))
LR_decay = (LR_fin/LR_start)**(1./num_epochs)
print("LR_decay = "+str(LR_decay))
# BTW, LR decay might good for the BN moving average...
save_path = "mnist_parameters.npz"
print("save_path = "+str(save_path))
shuffle_parts = 1
print("shuffle_parts = "+str(shuffle_parts))
print('Loading MNIST dataset...')
train_set = MNIST(which_set= 'train', start=0, stop = 50000, center = False)
valid_set = MNIST(which_set= 'train', start=50000, stop = 60000, center = False)
test_set = MNIST(which_set= 'test', center = False)
# bc01 format
# Inputs in the range [-1,+1]
# print("Inputs in the range [-1,+1]")
train_set.X = 2* train_set.X.reshape(-1, 1, 28, 28) - 1.
valid_set.X = 2* valid_set.X.reshape(-1, 1, 28, 28) - 1.
test_set.X = 2* test_set.X.reshape(-1, 1, 28, 28) - 1.
# flatten targets
train_set.y = np.hstack(train_set.y)
valid_set.y = np.hstack(valid_set.y)
test_set.y = np.hstack(test_set.y)
# Onehot the targets
train_set.y = np.float32(np.eye(10)[train_set.y])
valid_set.y = np.float32(np.eye(10)[valid_set.y])
test_set.y = np.float32(np.eye(10)[test_set.y])
# for hinge loss
train_set.y = 2* train_set.y - 1.
valid_set.y = 2* valid_set.y - 1.
test_set.y = 2* test_set.y - 1.
print('Building the MLP...')
# Prepare Theano variables for inputs and targets
input = T.tensor4('inputs')
target = T.matrix('targets')
LR = T.scalar('LR', dtype=theano.config.floatX)
mlp = lasagne.layers.InputLayer(
shape=(None, 1, 28, 28),
input_var=input)
mlp = lasagne.layers.DropoutLayer(
mlp,
p=dropout_in)
for k in range(n_hidden_layers):
mlp = binary_net.DenseLayer(
mlp,
binary=binary,
stochastic=stochastic,
H=H,
W_LR_scale=W_LR_scale,
nonlinearity=lasagne.nonlinearities.identity,
num_units=num_units)
mlp = lasagne.layers.BatchNormLayer(
mlp,
epsilon=epsilon,
alpha=alpha)
mlp = lasagne.layers.NonlinearityLayer(
mlp,
nonlinearity=activation)
mlp = lasagne.layers.DropoutLayer(
mlp,
p=dropout_hidden)
mlp = binary_net.DenseLayer(
mlp,
binary=binary,
stochastic=stochastic,
H=H,
W_LR_scale=W_LR_scale,
nonlinearity=lasagne.nonlinearities.identity,
num_units=10)
mlp = lasagne.layers.BatchNormLayer(
mlp,
epsilon=epsilon,
alpha=alpha)
train_output = lasagne.layers.get_output(mlp, deterministic=False)
# squared hinge loss
loss = T.mean(T.sqr(T.maximum(0.,1.-target*train_output)))
if binary:
# W updates
W = lasagne.layers.get_all_params(mlp, binary=True)
W_grads = binary_net.compute_grads(loss,mlp)
updates = lasagne.updates.adam(loss_or_grads=W_grads, params=W, learning_rate=LR)
updates = binary_net.clipping_scaling(updates,mlp)
# other parameters updates
params = lasagne.layers.get_all_params(mlp, trainable=True, binary=False)
updates = OrderedDict(list(updates.items()) + list(lasagne.updates.adam(loss_or_grads=loss, params=params,learning_rate=LR).items()))
else:
params = lasagne.layers.get_all_params(mlp, trainable=True)
updates = lasagne.updates.adam(loss_or_grads=loss, params=params, learning_rate=LR)
test_output = lasagne.layers.get_output(mlp, deterministic=True)
test_loss = T.mean(T.sqr(T.maximum(0.,1.-target*test_output)))
test_err = T.mean(T.neq(T.argmax(test_output, axis=1), T.argmax(target, axis=1)),dtype=theano.config.floatX)
# Compile a function performing a training step on a mini-batch (by giving the updates dictionary)
# and returning the corresponding training loss:
train_fn = theano.function([input, target, LR], loss, updates=updates)
# Compile a second function computing the validation loss and accuracy:
val_fn = theano.function([input, target], [test_loss, test_err])
print('Training...')
binary_net.train(
train_fn,val_fn,
mlp,
batch_size,
LR_start,LR_decay,
num_epochs,
train_set.X,train_set.y,
valid_set.X,valid_set.y,
test_set.X,test_set.y,
save_path,
shuffle_parts)
Может кто-нибудь пожалуйстапомогите решить эту ошибку.