结节识别模型
此模型从肺部扫描(3D图像)中获取少量(大块)作为输入,并将大块分为两类:
Class 0 : Chunk does not contain a nodule
Class 1 : Chunk contains a nodule
我在此部分中遇到此错误:UFuncTypeError:ufunc'add'不包含具有签名匹配类型的循环(dtype('dtype('
def get_validation_batch(validation_x_ids,validation_y,batch_number):num_images = len(validation_x_ids)
count = 0
start_index = batch_number * FLAGS.batch_size
end_index = start_index + FLAGS.batch_size
end_index = num_images if end_index > num_images else end_index
real_batch_size = end_index - start_index
validation_x = np.ndarray([real_batch_size, FLAGS.chunk_size, FLAGS.chunk_size, FLAGS.chunk_size, 1], dtype=np.float32)
for chunk_id in validation_x_ids[start_index : end_index]:
chunk = np.load(DATA_PATH + chunk_id + '_X.npy').astype(np.float32, copy=False)
validation_x[count, :, :, :, :] = img_to_rgb(chunk)
count = count + 1
return validation_x, validation_y[start_index : end_index]
错误是由于np.load(...)
语句中字符串连接中的数据类型不匹配,其中chund_id
是从np.ndarray()
获得的整数,而'_X.npy'
是字符串类型。