*/
public final MLMethod create(final String architecture, final int input,
final int output) {
if( input<=0 ) {
throw new EncogError("Must have at least one input for feedforward.");
}
if( output<=0 ) {
throw new EncogError("Must have at least one output for feedforward.");
}
final BasicNetwork result = new BasicNetwork();
final List<String> layers = ArchitectureParse.parseLayers(architecture);
ActivationFunction af = new ActivationLinear();
int questionPhase = 0;
for (final String layerStr : layers) {
int defaultCount;
// determine default
if (questionPhase == 0) {
defaultCount = input;
} else {
defaultCount = output;
}
final ArchitectureLayer layer = ArchitectureParse.parseLayer(
layerStr, defaultCount);
final boolean bias = layer.isBias();
String part = layer.getName();
if (part != null) {
part = part.trim();
} else {
part = "";
}
ActivationFunction lookup = this.factory.create(part);
if (lookup!=null) {
af = lookup;
} else {
if (layer.isUsedDefault()) {
questionPhase++;
if (questionPhase > 2) {
throw new EncogError("Only two ?'s may be used.");
}
}
if (layer.getCount() == 0) {
throw new EncogError("Unknown architecture element: "
+ architecture + ", can't parse: " + part);
}
result.addLayer(new BasicLayer(af, bias,
layer.getCount()));