Mercurial > pylearn
comparison dataset.py @ 216:4b7e89b75e2b
Modified ArrayDataSet's handling of column fields.
Previously, if a fieldname were associated with an integer column index (by
opposition to a column range or slice) then it would be returned as a Nx1
matrix.
Now if a fieldname is associated with an integer column index, then it will
make a field which is a vector of length N.
The old behaviour can still be achieved by associating a fieldname with
the slice(col, col+1).
author | James Bergstra <bergstrj@iro.umontreal.ca> |
---|---|
date | Thu, 22 May 2008 19:07:51 -0400 |
parents | bd728c83faff |
children | df3fae88ab46 |
comparison
equal
deleted
inserted
replaced
215:6fa8fbb0c3f6 | 216:4b7e89b75e2b |
---|---|
243 assert offset+minibatch_size<=self.L | 243 assert offset+minibatch_size<=self.L |
244 ds_nbatches = (self.L-self.next_row)/self.minibatch_size | 244 ds_nbatches = (self.L-self.next_row)/self.minibatch_size |
245 if n_batches is not None: | 245 if n_batches is not None: |
246 ds_nbatches = min(n_batches,ds_nbatches) | 246 ds_nbatches = min(n_batches,ds_nbatches) |
247 if fieldnames: | 247 if fieldnames: |
248 assert dataset.hasFields(*fieldnames) | 248 if not dataset.hasFields(*fieldnames): |
249 raise ValueError('field not present', fieldnames) | |
249 else: | 250 else: |
250 self.fieldnames=dataset.fieldNames() | 251 self.fieldnames=dataset.fieldNames() |
251 self.iterator = self.dataset.minibatches_nowrap(self.fieldnames,self.minibatch_size, | 252 self.iterator = self.dataset.minibatches_nowrap(self.fieldnames,self.minibatch_size, |
252 ds_nbatches,self.next_row) | 253 ds_nbatches,self.next_row) |
253 | 254 |
967 | 968 |
968 # check consistency and complete slices definitions | 969 # check consistency and complete slices definitions |
969 for fieldname, fieldcolumns in self.fields_columns.items(): | 970 for fieldname, fieldcolumns in self.fields_columns.items(): |
970 if type(fieldcolumns) is int: | 971 if type(fieldcolumns) is int: |
971 assert fieldcolumns>=0 and fieldcolumns<data_array.shape[1] | 972 assert fieldcolumns>=0 and fieldcolumns<data_array.shape[1] |
972 self.fields_columns[fieldname]=[fieldcolumns] | 973 |
974 if 0: | |
975 #I changed this because it didn't make sense to me, | |
976 # and it made it more difficult to write my learner. | |
977 # If it breaks stuff, let's talk about it. | |
978 # - James 22/05/2008 | |
979 self.fields_columns[fieldname]=[fieldcolumns] | |
980 else: | |
981 self.fields_columns[fieldname]=fieldcolumns | |
982 | |
973 elif type(fieldcolumns) is slice: | 983 elif type(fieldcolumns) is slice: |
974 start,step=None,None | 984 start,step=None,None |
975 if not fieldcolumns.start: | 985 if not fieldcolumns.start: |
976 start=0 | 986 start=0 |
977 if not fieldcolumns.step: | 987 if not fieldcolumns.step: |