def load(self, backend=None, experiment=None): if self.inputs['train'] is not None or self.inputs['test'] is not None: return if 'repo_path' not in self.__dict__: raise AttributeError('repo_path not specified in config') if 'item_size' not in self.__dict__: try: # infer item_size from DataLayer self.item_size = experiment.model.layers[0].nout except AttributeError: raise AttributeError('item_size not specified in config' ' and cannot be inferred') if 'noutputs' not in self.__dict__: try: # infer noutputs from CostLayer self.noutputs = experiment.model.layers[-1].nin except AttributeError: raise AttributeError('noutputs not specified in config' ' and cannot be inferred') self.repo_path = os.path.expandvars(os.path.expanduser(self.repo_path)) self.rootdir = os.path.join(self.repo_path, self.__class__.__name__) self.batchdata = np.zeros((self.item_size, self.batch_size), dtype=self.input_dtype) if self.live: from neon.ipc.shmem import Server self.predict = True req_size = (np.dtype(self.input_dtype).itemsize * self.batch_size * self.item_size) res_size = (np.dtype(self.target_dtype).itemsize * self.noutputs * self.batch_size) self.server = Server(req_size=req_size, res_size=res_size) return
# You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ---------------------------------------------------------------------------- import logging from neon.ipc.shmem import Server logging.basicConfig(level=20) logger = logging.getLogger(__name__) # server1 = Server(req_size=1, res_size=1, channel_id="one") # server2 = Server(req_size=1, res_size=1, channel_id="two") # Generate posix ipc components with default name server3 = Server(req_size=1, res_size=1) server3.send('x') while True: data = server3.receive() print "received: ", data server3.send(data)