public List<Integer> getTrainImgIds(
			HashMap<Integer, RawImageInstance> rawInstance, int zeroImageSize,
			int oneImageSize) {
		if (trainImgIds == null) {
			// shuffle
			ArrayList<Integer> allIds = new ArrayList<Integer>(
					rawInstance.keySet());
			Collections.shuffle(allIds, new Random(System.currentTimeMillis()));

			// select training data
			List<Integer> zeroImageIds = new LinkedList<Integer>();
			List<Integer> oneImageIds = new LinkedList<Integer>();
			Iterator<Integer> idIt = allIds.iterator();
			int zeroIndex = 0, oneIndex = 0;
			while (idIt.hasNext()
					&& (zeroIndex < zeroImageSize || oneIndex < oneImageSize)) {
				int id = idIt.next();
				if (rawInstance.get(id).getLabel() == 0
						&& zeroIndex < zeroImageSize) {
					zeroImageIds.add(id);
					zeroIndex++;
				}
				if (rawInstance.get(id).getLabel() == 1
						&& oneIndex < oneImageSize) {
					oneImageIds.add(id);
					oneIndex++;
				}
			}
			List<Integer> trainIds = new LinkedList<Integer>(zeroImageIds);
			trainIds.addAll(oneImageIds);
			trainImgIds = trainIds;
		}
		return trainImgIds;
	}