Автоматизированная система колоризации полутонового изображения
Дипломная работа - Компьютеры, программирование
Другие дипломы по предмету Компьютеры, программирование
Network(this);.layers.add(layer);
}void addLayer(int idx, Layer layer) {.setParentNetwork(this);.layers.add(idx, layer);
}void removeLayer(Layer layer) {.layers.remove(layer);
}void removeLayerAt(int idx) {.layers.remove(idx);
getLayersIterator(){this.layers.iterator();">}Iterator getLayersIterator() {this.layers.iterator();
getLayers(){this.layers;">}List getLayers() {this.layers;
}Layer getLayerAt(int idx) {this.layers.get(idx);
}int indexOf(Layer layer) {this.layers.indexOf(layer);
}int getLayersCount() {this.layers.size();
}void setInput(double... inputVector) throws RuntimeException {(inputVector.length != inputNeurons.size()) {new RuntimeException("Input vector size does not match network input dimension!");
}i = 0;(Neuron neuron : this.inputNeurons) {.setInput(inputVector[i]);++;
}
}double[] getOutput() {[] outputVector = new double[outputNeurons.size()];i = 0;(Neuron neuron : this.outputNeurons) {[i] = neuron.getOutput();++;
}outputVector;
}void calculate() {(Layer layer : this.layers) {.calculate();
}
}void reset() {(Layer layer : this.layers) {.reset();
}
}void run() {.calculate();
}void learnInNewThread(TrainingSet trainingSetToLearn) {.setTrainingSet(trainingSetToLearn);= new Thread(learningRule);.setStarted();.start();
}void learnInNewThread(TrainingSet trainingSetToLearn, LearningRule learningRule) {(learningRule);.setTrainingSet(trainingSetToLearn);= new Thread(learningRule);.setStarted();.start();
}void learnInSameThread(TrainingSet trainingSetToLearn) {.setTrainingSet(trainingSetToLearn);.setStarted();.run();
}void learnInSameThread(TrainingSet trainingSetToLearn, LearningRule learningRule) {(learningRule);.setTrainingSet(trainingSetToLearn);.setStarted();.run();
}void stopLearning() {.stopLearning();
}void pauseLearning() {(learningRule instanceof IterativeLearning)
((IterativeLearning) learningRule).pause();
}void resumeLearning() {(learningRule instanceof IterativeLearning)
((IterativeLearning) learningRule).resume();
}void randomizeWeights() {(Layer layer : this.layers) {.randomizeWeights();
}
}void randomizeWeights(double minWeight, double maxWeight) {(Layer layer : this.layers) {.randomizeWeights(minWeight, maxWeight);
}
}void initializeWeights(double value) {(Layer layer : this.layers) {.initializeWeights(value);
}
}void initializeWeights(Random generator) {(Layer layer : this.layers) {.initializeWeights(generator);
}
}void initializeWeights(double min, double max) {(Layer layer : this.layers) {.initializeWeights(min, max);
}
}NeuralNetworkType getNetworkType() {type;
}void setNetworkType(NeuralNetworkType type) {.type = type;
getInputNeurons(){this.inputNeurons;">}List getInputNeurons() {this.inputNeurons;
}void setInputNeurons(List inputNeurons) {.inputNeurons = inputNeurons;
getOutputNeurons(){this.outputNeurons;">}List getOutputNeurons() {this.outputNeurons;
}void setOutputNeurons(List outputNeurons) {.outputNeurons = outputNeurons;
}LearningRule getLearningRule() {this.learningRule;
}void setLearningRule(LearningRule learningRule) {.setNeuralNetwork(this);.learningRule = learningRule;
}Thread getLearningThread() {learningThread;
}void notifyChange() {();();();
}void createConnection(Neuron fromNeuron, Neuron toNeuron, double weightVal) {connection = new Connection(fromNeuron, toNeuron, weightVal);.addInputConnection(connection);
}
@OverrideString toString() {(plugins.containsKey("LabelsPlugin")) {labelsPlugin = ((LabelsPlugin) this.getPlugin(LabelsPlugin.class));label = labelsPlugin.getLabel(this);(label != null) return label;
}super.toString();
}void save(String filePath) {out = null;{file = new File(filePath);= new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream(file)));.writeObject(this);.flush();
} catch (IOException ioe) {new RuntimeException("Error while saving:", ioe);
} finally {(out != null) {{.close();
} catch (IOException e) {new RuntimeException("Error while saving network", e);
}
}
}
}static NeuralNetwork load(String filePath) {oistream = null;{file = new File(filePath);(!file.exists()) {new RuntimeException("Cannot find file: " + filePath);
}= new ObjectInputStream(new BufferedInputStream(new FileInputStream(filePath)));nnet = (NeuralNetwork) oistream.readObject();nnet;
} catch (IOException ioe) {new RuntimeException("Cannot load network: ", ioe);
} catch (ClassNotFoundException cnfe) {new RuntimeException("Cannot load network: ", cnfe);
} finally {(oistream != null) {{.close();
} catch (IOException ioe) {new RuntimeException("OIStream error: ", ioe);
}
}
}
}static NeuralNetwork load(InputStream inputStream) {oistream = null;{= new ObjectInputStream(new BufferedInputStream(inputStream));nnet = (NeuralNetwork) oistream.readObject();nnet;
} catch (IOException ioe) {new RuntimeException("Cannot load network: ", ioe);
} catch (ClassNotFoundException cnfe) {new RuntimeException("Cannot load network: ", cnfe);
} finally {(oistream != null) {{.close();
} catch (IOException ioe) {new RuntimeException("OIStream error: ", ioe);
}
}
}
}void addPlugin(PluginBase plugin) {.setParentNetwork(this);.plugins.put(plugin.getClass(), plugin);
}PluginBase getPlugin(Class pluginClass) {this.plugins.get(pluginClass);
}void removePlugin(String pluginName) {.plugins.remove(pluginName);
}String getLabel() {label;
}void setLabel(String label) {
this.label = label;
}
}
Класс многослойного персептрона:
neuronsInLayers){neuronProperties=newNeuronProperties();.setProperty("useBias",true);.setProperty("transferFunction",TransferFunctionType.SIGMOID);.createNetwork(neuronsInLayers,neuronProperties);">public class MultiLayerPerceptron extends NeuralNetwork {static final long serialVersionUID = 2L;MultiLayerPerceptron(List neuronsInLayers) {neuronProperties = new NeuronProperties();.setProperty("useBias", true);.setProperty("transferFunction", TransferFunctionType.SIGMOID);.createNetwork(neuronsInLayers, neuronProperties);
neuronsInLayersVector=newVector();(int i = 0; i < neuronsInLayers.length; i++).add(new Integer(neuronsInLayers[i]));.createNetwork(neuronsInLayersVector, neuronProperties);
neuronsInLayersVector=newVector();(int i = 0; i < neuronsInLayers.length; i++).add(new Integer(neuronsInLayers[i]));.createNetwork(neuronsInLayersVector, neuronProperties);
}MultiLayerPerceptron(List neuronsInLayers, TransferFunctionType transferFunctionType) {neuronProperties = new NeuronProperties();.setProperty("useBias", true);.setProperty("transferFunction", transferFunctionType);.createNetwork(neuronsInLayers, neuronProperties);
}MultiLayerPerceptron(List neuronsInLayers, NeuronProperties neuronProperties) {.createNetwork(neuronsInLayers, neuronProperties);
neuronsInLayers,NeuronPropertiesneuronProperties){.setNetworkType(NeuralNetworkType.MULTI_LAYER_PERCEPTRON);inputNeuronProperties=newNeuronProperties(InputNeuron.class,TransferFunctionType.LINEAR);layer=LayerFactory.createLayer(neuronsInLayers.get(0),inputNeuronProperties);useBias=true;(neuronProperties.hasProperty("useBias")){=(Boolean)neuronProperties.getProperty("useBias");">}void createNetwork(List neuronsInLayers, NeuronProperties neuronProperties) {.setNetworkType(NeuralNetworkType.MULTI_LAYER_PERCEPTRON);inputNeuronProperties = new NeuronProperties(InputNeuron.class, TransferFunctionType.LINEAR);layer = LayerFactory.createLayer(neuronsInLayers.get(0), inputNeuronProperties);useBias = true;(neuronProperties.hasProperty("useBias")) {= (Boolean) neuronProperties.getProperty("useBias");
}(useBias) {.addNeuron(new BiasNeuron());
}.addLayer(layer);prevLayer = layer;(int layerIdx = 1; layerIdx < neuronsInLayers.size(); layerIdx++) {neuronsNum = neuronsInLayers.get(l