code:
def train_one_epoch(sess, ops, train_writer):
‘’’ Training for one epoch on the frustum dataset.
ops is dict mapping from string to tf ops
‘’’
is_training = True
log_string(str(datetime.now()))
# Shuffle train samples
train_idxs = np.arange(0, len(TRAIN_DATASET))
np.random.shuffle(train_idxs)
num_batches = len(TRAIN_DATASET)/BATCH_SIZE
num_batches = int(num_batches)
# To collect statistics
total_correct = 0
total_seen = 0
loss_sum = 0
iou2ds_sum = 0
iou3ds_sum = 0
iou3d_correct_cnt = 0
# Training with batches
for batch_idx in range(num_batches):
start_idx = batch_idx * BATCH_SIZE
end_idx = (batch_idx+1) * BATCH_SIZE
batch_data, batch_label, batch_center, \
batch_hclass, batch_hres, \
batch_sclass, batch_sres, \
batch_rot_angle, batch_one_hot_vec = \
get_batch(TRAIN_DATASET, train_idxs, start_idx, end_idx,
NUM_POINT, NUM_CHANNEL)
feed_dict = {ops['pointclouds_pl']: batch_data,
ops['one_hot_vec_pl']: batch_one_hot_vec,
ops['labels_pl']: batch_label,
ops['centers_pl']: batch_center,
ops['heading_class_label_pl']: batch_hclass,
ops['heading_residual_label_pl']: batch_hres,
ops['size_class_label_pl']: batch_sclass,
ops['size_residual_label_pl']: batch_sres,
ops['is_training_pl']: is_training,}
summary, step, _, loss_val, logits_val, centers_pred_val, \
iou2ds, iou3ds = \
sess.run([ops['merged'], ops['step'], ops['train_op'], ops['loss'],
ops['logits'], ops['centers_pred'],
ops['end_points']['iou2ds'], ops['end_points']['iou3ds']],
feed_dict=feed_dict)
train_writer.add_summary(summary, step)
preds_val = np.argmax(logits_val, 2)
correct = np.sum(preds_val == batch_label)
total_correct += correct
total_seen += (BATCH_SIZE*NUM_POINT)
loss_sum += loss_val
iou2ds_sum += np.sum(iou2ds)
iou3ds_sum += np.sum(iou3ds)
iou3d_correct_cnt += np.sum(iou3ds>=0.7)
if (batch_idx+1)%10 == 0:
log_string(' -- %03d / %03d --' % (batch_idx+1, num_batches))
log_string('mean loss: %f' % (loss_sum / 10))
log_string('segmentation accuracy: %f' % \
(total_correct / float(total_seen)))
log_string('box IoU (ground/3D): %f / %f' % \
(iou2ds_sum / float(BATCH_SIZE*10), iou3ds_sum / float(BATCH_SIZE*10)))
log_string('box estimation accuracy (IoU=0.7): %f' % \
(float(iou3d_correct_cnt)/float(BATCH_SIZE*10)))
total_correct = 0
total_seen = 0
loss_sum = 0
iou2ds_sum = 0
iou3ds_sum = 0
iou3d_correct_cnt = 0
the issue:
Traceback (most recent call last):
File “/home/aya/mywork/frustum-pointnets-master/train/train.py”, line 380, in
train()
File “/home/aya/mywork/frustum-pointnets-master/train/train.py”, line 204, in train
train_one_epoch(sess, ops, train_writer)
File “/home/aya/mywork/frustum-pointnets-master/train/train.py”, line 257, in train_one_epoch
sess.run([ops[‘merged’], ops[‘step’], ops[‘train_op’], ops[‘loss’],
File “/home/aya/.local/lib/python3.8/site-packages/tensorflow/python/client/session.py”, line 970, in run
result = self._run(None, fetches, feed_dict, options_ptr,
File “/home/aya/.local/lib/python3.8/site-packages/tensorflow/python/client/session.py”, line 1178, in _run
fetch_handler = _FetchHandler(
File “/home/aya/.local/lib/python3.8/site-packages/tensorflow/python/client/session.py”, line 488, in init
self._fetch_mapper = _FetchMapper.for_fetch(fetches)
File “/home/aya/.local/lib/python3.8/site-packages/tensorflow/python/client/session.py”, line 269, in for_fetch
return _ListFetchMapper(fetch)
File “/home/aya/.local/lib/python3.8/site-packages/tensorflow/python/client/session.py”, line 381, in init
self._mappers = [_FetchMapper.for_fetch(fetch) for fetch in fetches]
File “/home/aya/.local/lib/python3.8/site-packages/tensorflow/python/client/session.py”, line 381, in
self._mappers = [_FetchMapper.for_fetch(fetch) for fetch in fetches]
File “/home/aya/.local/lib/python3.8/site-packages/tensorflow/python/client/session.py”, line 265, in for_fetch
raise TypeError(f’Argument fetch
= {fetch} has invalid type ’
TypeError: Argument fetch
= None has invalid type “NoneType”. Cannot be None