/** * Load a file from the directory that this object refers to. * @param name The name to load. * @return The object. */ public final Object loadFromDirectory(final String name) { final File path = new File(this.parent, name); return EncogDirectoryPersistence.loadObject(path); }
/** * Load an EG object as a reousrce. * @param res The resource name. * @return The loaded object. */ public static Object loadResourceObject(final String res) { InputStream is = null; try { is = ResourceInputStream.openResourceInputStream(res); return loadObject(is); } finally { try { if( is!=null ) { is.close(); } } catch(IOException ex) { } } }
/** * Load the specified object. * @param file The file to load. * @return The loaded object. */ public static Object loadObject(final File file) { FileInputStream fis = null; try { fis = new FileInputStream(file); final Object result = EncogDirectoryPersistence.loadObject(fis); return result; } catch (final IOException ex) { throw new PersistError(ex); } finally { if (fis != null) { try { fis.close(); } catch (final IOException e) { EncogLogging.log(e); } } } }
public static void load(File f, CARunner runner) { try { Universe universe = (Universe)EncogDirectoryPersistence.loadObject( new File(FileUtil.forceExtension(f.toString(), "eg"))); CAProgram physics = (CAProgram)SerializeObject.load( new File(FileUtil.forceExtension(f.toString(), "bin"))); physics.setSourceUniverse(universe); runner.init(universe,physics); } catch (IOException ex) { throw new CellularAutomataError(ex); } catch (ClassNotFoundException ex) { throw new CellularAutomataError(ex); } } }
/** * Obtain the ML method. * @return The method. */ public MLMethod obtainMethod() { final String resourceID = getProp().getPropertyString( ScriptProperties.ML_CONFIG_MACHINE_LEARNING_FILE); final File resourceFile = getScript().resolveFilename(resourceID); final MLMethod method = (MLMethod) EncogDirectoryPersistence .loadObject(resourceFile); if (!(method instanceof MLMethod)) { throw new AnalystError( "The object to be trained must be an instance of MLMethod. " + method.getClass().getSimpleName()); } return method; }
return BasicML.class.cast(NNModel.loadFromStream(pair.getInput())); } else { return BasicML.class.cast(EncogDirectoryPersistence.loadObject(pair.getInput()));
.loadObject(methodFile);
.loadObject(methodFile);
/** * GEnerate from a machine learning method. * * @param mainClass * The main class. * @param method * The filename of the method. * @return The newly created node. */ private EncogProgramNode generateForMethod( final EncogProgramNode mainClass, final File method) { if (this.embedData) { final MLEncodable encodable = (MLEncodable) EncogDirectoryPersistence .loadObject(method); final double[] weights = new double[encodable.encodedArrayLength()]; encodable.encodeToArray(weights); mainClass.createArray("WEIGHTS", weights); } return mainClass.createNetworkFunction("createNetwork", method); }
models.add(BasicML.class.cast(NNModel.loadFromStream(pair.getInput()))); } else { models.add(BasicML.class.cast(EncogDirectoryPersistence.loadObject(pair.getInput())));
.loadObject(methodFile);
.loadObject(methodFile); final FlatNetwork flat = ((BasicNetwork) method).getFlat();
outputID); MLMethod m = (MLMethod) EncogDirectoryPersistence.loadObject(resourceFile);
.loadObject(resourceFile); getAnalyst().setMethod(method);
.loadObject(methodFile); FlatNetwork flat = ((BasicNetwork) method).getFlat();