Example #1
0
	def __init__(self, db_path, db_type, kmeans_file):
		# initialize the renderedImages dataset first
		super().__init__(db_path, db_type, 'quaternion')
		# add the kmeans part
		self.kmeans = pickle.load(open(kmeans_file, 'rb'))
		self.num_clusters = self.kmeans.n_clusters
		self.kmeans.cluster_centers_ = convert_dictionary(self.kmeans.cluster_centers_)
 def __init__(self, alpha, kmeans_file, my_loss):
     super().__init__()
     self.alpha = alpha
     kmeans = pickle.load(open(kmeans_file, 'rb'))
     self.cluster_centers = Variable(
         torch.from_numpy(convert_dictionary(
             kmeans.cluster_centers_)).float()).cuda()
     self.n_clusters = kmeans.n_clusters
     self.my_loss = my_loss
     self.kl = nn.KLDivLoss().cuda()
 def __init__(self, alpha, kmeans_file, my_loss=None):
     super().__init__()
     self.alpha = alpha
     kmeans = pickle.load(open(kmeans_file, 'rb'))
     self.cluster_centers_ = Variable(
         torch.from_numpy(convert_dictionary(
             kmeans.cluster_centers_)).float()).cuda()
     if my_loss is None:
         self.mse = nn.MSELoss().cuda()
     else:
         self.mse = my_loss
     self.ce = nn.CrossEntropyLoss().cuda()
Example #4
0
args = parser.parse_args()
print(args)
# assign GPU
os.environ['CUDA_VISIBLE_DEVICES'] = args.gpu_id

# save stuff here
results_file = os.path.join('results', args.save_str)
model_file = os.path.join('models', args.save_str + '.tar')
plots_file = os.path.join('plots', args.save_str)
log_dir = os.path.join('logs', args.save_str)

# kmeans data
kmeans_file = 'data/kmeans_dictionary_axis_angle_' + str(
    args.dict_size) + '.pkl'
kmeans = pickle.load(open(kmeans_file, 'rb'))
kmeans_dict = convert_dictionary(kmeans.cluster_centers_)
num_clusters = kmeans.n_clusters

# relevant variables
ndim = 4
num_classes = len(classes)

if not args.multires:
    criterion = RelaXedProbabilisticLossQ(1.0, kmeans_file,
                                          geodesic_loss(reduce=False).cuda())
else:
    criterion = RelaXedProbabilisticMultiresLossQ(
        1.0, kmeans_file,
        geodesic_loss(reduce=False).cuda())

# DATA